Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Load Assembly at Runtime

More
13 Jun 2012 07:12 #887 by support
Hello,
we have made improvements to the assembly loading process, with better support for dynamic loading. Here is one of the expected scenarios:

You write an assembly - a class library that references EasyOpcClassic, and uses the types from it.
You place this assembly, together EasyOpcClassic assembly, and all its dependent assemblies, into any directory.
You write an application that dynamically loads your class libray. The application can be located in a directory that is different from the directory of your class library.

We have updated the product on our Web site, please download the current package. It should identify itself as 5.12.1309.1.
I would be curious to know whether this works for you, especially in the MEF environment. For start, please remove the extra "tricks" introduced in attempts to make it work, and simply do it in the standard way.
Best regards,

Please Log in or Create an account to join the conversation.

More
12 Jun 2012 06:45 #886 by support
Hello,
I wrote a test class library/dynamic load application (no MEF involved), and was able to get the behavior same or similar to what you are observing. Let's address this one first; if this one is resolved, MEF will probably work as well.
Please allow a few days before more information can be posted, as well.
Best regards

Please Log in or Create an account to join the conversation.

More
07 Jun 2012 16:15 #884 by Andrew
Replied by Andrew on topic Re: Load Assembly at Runtime
Hi Zbynek,
thank you for your reply.
I'll try and put together a simple project for you to test. My apologies if it takes a few days, things are rather busy at the moment.
Regards,
Andrew

Please Log in or Create an account to join the conversation.

More
07 Jun 2012 07:53 #883 by support
Hi.
I do not know the reason for the problem, but I can "guess" where it is coming from. It will probably be related to the way the component loads its dependent assemblies. There is quite a bit of trickery used internally, because the core of the component (internal, invisible to the developer) is a mixed managed+native code, and it therefore exists in 2 build configurations (x86 and x64). It is implemented in internal assemblies that are stored as resources in the main assembly, and loaded dynamically. It has been carefully developed, but one can imagine that in some special situations (mainly different hosting environments) problems can appear.
We have not tested with MEF. Can you post a simple project exhibiting the problem? I whould then be able to analyze it and hopefully come with a solution.
Best regards,
Zbynek Zahradnik

Please Log in or Create an account to join the conversation.

More
06 Jun 2012 19:14 #882 by Andrew
Hi,
I am evaluating the trial version of QuickOPC.NET. So far it has been great. Very easy to implement and integrate. I am faced with one final issue I must overcome before committing to QuickOPC as a solution.
I am using the .Net managed extensibility framework to load modules at runtime. Specifically I am loading at runtime the OPC client that I have written using the QuickOPC libraries. When my client tries to instantiate EasyDAClient() I am getting a
System.TypeInitializationException: The type initializer for 'OpcLabs.EasyOpc.DataAccess.EasyDAClient' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'OpcLabs.EasyOpcClassicInternal, Version=5.12.1305.1, Culture=neutral, PublicKeyToken=6faddca41dacb409' or one of its dependencies. The system cannot find the file specified.
Before loading the client and before importing the MEF libraries I am loading the various OPC Labs assemblies (BaseLib, EasyOPCClassic, EasyOPCClassicInternal) using Assembly.LoadFrom but that doesn't help. Even explicitly loading the assemblies in my client as below doesn't help:


Assembly.LoadFrom(path + "OpcLabs.BaseLib.dll");
Assembly.LoadFrom(path + "OpcLabs.EasyOpcClassic.dll");
Assembly.LoadFrom(path + "OpcLabs.EasyOpcClassicInternal.dll");
_client = new EasyDAClient();

If I put the above assemblies in the executing assemblies directory (somewhat against the point of using MEF) I get a different error:

Unable to cast object of type 'OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient' to type 'OpcLabs.EasyOpcRaw.DataAccess.IRawEasyDAClient'.
Any thoughts on what I need to do so I can load these libraries dynamically at runtime?

Thank you for any help,
Andrew

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.050 seconds