.NET-Event "AssemblyResolve" only fires in Dynamics NAV on client side, not server side?
FS_9
Member Posts: 1
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):
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?
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?
0
Answers
-
Hi FS_9,
If you make the property of your .Net type variable to true it will never run on the server side. To run the dll on the server side place you dll and all required resources(dlls) in the Add-ins folder of the server. The path could be like C:\Program Files\Microsoft Dynamics NAV\90\Service\Add-ins
Best Regards:
Zaid Tariq
Dynamics NAV/365 BC Developer at Dynamics 360
please like / agree / verify my answer, if was helpful.1
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions