Calling a .NET dll from NAV 2009R2

dna
Member Posts: 6
Hi,
http://msdn.microsoft.com/en-us/library/gg502473.aspx but I can't figure out what's the problem.
I have registered my dll into the GAC and created a variable in NAV as mentioned in the link above.
Name: test, DataType:DotNet, Subtype: MyDll, version ..........
My dll contains a single class with a static method which his called like that :
Then when opening the page containing this modification boum :
I have no idea why NAV try to create an instance, it should not. If I uninstall the dll from the GAC the same message appears. I tried to put the dll in the Add-ins folder but still the same result.
Any help will be appreciated
http://msdn.microsoft.com/en-us/library/gg502473.aspx but I can't figure out what's the problem.
I have registered my dll into the GAC and created a variable in NAV as mentioned in the link above.
Name: test, DataType:DotNet, Subtype: MyDll, version ..........
My dll contains a single class with a static method which his called like that :
test.StaticMethod();
Then when opening the page containing this modification boum :
This message is for C/AL programmers: Unable to create an instance of .NET object: assembly MyDll ....
I have no idea why NAV try to create an instance, it should not. If I uninstall the dll from the GAC the same message appears. I tried to put the dll in the Add-ins folder but still the same result.
Any help will be appreciated

0
Comments
-
As far as I understand the usage of .NET in NAV you need an instance of any Object that you want to use. That means you have to either call the constructor of that Object or use the result of another method that gives you an instance of that Object.
In your linked example the .NET variable named 'xml' is instanced by constructor:xml := xml.XmlDocument();
The .NET variable named 'items' is "instanced" by result value:items := xml.SelectNodes('/rss/channel/item');
"Money is likewise the greatest chance and the greatest scourge of mankind."0 -
Hi einsTeIn.NET and thanks for your answer.In your linked example the .NET variable named 'xml' is instanced by constructor:
Code: Select all
xml := xml.XmlDocument();
The .NET variable named 'items' is "instanced" by result value:
Code: Select all
items := xml.SelectNodes('/rss/channel/item');
I finally succeed to load my dll. I have no clue why. I have clean my system and put the dll in the Add-ins folder of NAV. Hocus Pocus !
Thanks for the help anyway.0 -
there still is a need to instanciate the object. .NET is OO. Even static objects are instanciated, but only once.
And any addin .dll is required to be in the addin folder before NAV can instanciate it.0 -
there still is a need to instanciate the object. .NET is OO. Even static objects are instanciated, but only once.And any addin .dll is required to be in the addin folder before NAV can instanciate it.If the assembly that you want to reference is a custom assembly and not installed in the global assembly cache, then copy the assembly to the Add-ins folder of the Microsoft Dynamics NAV installation folder.0
-
And are you using client side dotnet or server side? If serverside, is the assembly in GAC on server?0
-
This message is for C/AL programmers: Unable to create an instance of .NET object: assembly MyDll ....
Having installed my dll in the server's GAC, I kept getting this message also.
It went away when I restarted the navision service on the server0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions