Quantcast
Channel: NAV Three Tier — mibuso.com
Viewing all articles
Browse latest Browse all 10032

.NET-Event "AssemblyResolve" only fires in Dynamics NAV on client side, not server side?

$
0
0
So, the setup in this issue is maybe a bit complicated. I will explain it with editted names and try to keep it simple:

I have a .NET-Assembly "Processor.dll" with a single class "Processor" that I want to make use of inside a CodeUnit in Dynamics NAV 2017.

"Processor" requires another dll "Logger", which is held inside a file "container.libz" created with - as the name suggests - LibZ.

Inside a method of "Processor" I resolve the container and load the "Logger"-Assembly. A simple Version of the Code would look like this:

In NAV CodeUnit (given that "P" is the Processor variable and "T" a text variable):
P := P.Processor;
T := P.DoStuff;
MESSAGE(T);
In the Processor class:
public Processor()
{
    Initialize(); 
    //this among other things causes LibzResolver to be initialized
}

public string DoStuff()
{
    LibzResolver.RegisterFileContainer("container.libz");
    Assembly dll = AppDomain.CurrentDomain.Load("Logger");

    //more code using the dll
    return someText;
}
The assembly is found as LibzResolver makes the container's contents known to the domain by subscribing to the AssemblyResolve Event.

So problem here is the following: This code in fact works fine in test Applications and when running the NAV CodeUnit on the client (Setting RunOnClient = Yes for "P")

When I try to run this code on server side though (Setting RunOnClient = No for "P"), the AssemblyResolve Event is not fired. As a result the dll is not found the code stops with a FileLoadException.

I checked various articles about AssemblyResolve and .NET-Assemblies in NAV, but I did not find anything that applied to my case or could be applied at all.

Does anybody have an idea what may cause this behaviour?

Viewing all articles
Browse latest Browse all 10032

Trending Articles