This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Using a custom class defined in a .dll file

Brian - Tuesday, September 7, 2010 11:58 PM:

I'm investigating how to extend Innovator using classes in .dll files.

I have a simple .dll file that I have created.

Following the same process as described in the "How to consume a web service" Wiki article I have installed the dll in the ..Innovator/Server/bin directory and added an entry in the method-config.xml.

When I restart Innovator I don't get any error messages and the login screen comes up, however, the "databases" list is empty.

Removing the .dll file restores everything to the way it should be.

Can anyone suggest what I might be doing wrong?

The classes in the .dll file work as I built a command line test harness to ensure that the code was souund before trying to use it in Innovator.

Cheers,

Brian.



aknourenko - Wednesday, September 8, 2010 11:18 AM:

I think the problem is that IIS fails to load your dll as part of the InnovatorServer web application but without having the source code of your dll it's difficult to be more specific. Couple of suggestions:

a) you may try to enable tracing in InnovatorServerweb.config and look at the trace log

b) you may try to create a simple aspx page which uses your dll (not a console application as you did) and see that it works

c) although by default Innovator server methods assume that your server code is just a plain code that is simply plugged into a template there is a trick that you can use to have classes andor methods embedded into your code. Using this trick you can embed your class(es) into your server method without need for additional external dll and without updating method-config.xml. Here is the trick (see comments with ">>>>>" in the code that explains the trick); let's assume that the method is written in C#:

//MethodTemplateName=CSharpInOut;

if (InnovatorServerASP == null)
  throw new ArgumentNullException("InnovatorServerASP");


Innovator inn = new Innovator( InnovatorServerASP );
MyCustomClass  mcc = new MyCustomClass( inn, inDom, outDom );
mcc.doIt();


}  // >>>> When the code is plugged into the "CSharpInOut" template the closing bracket  matches the template open bracket which closes the method and allows to add the inner class below

public class MyCustomClass
{

     // Implementation of your class with data members; methods; etc.

     // ....

     public MyCustomClass(Innovator inn, XmlDocument inDom, XmlDocument outDom)

     {

         // ...

     }

     public void doIt()

     {

         // ....

      }

// >>>>>>> Note that there is NO closing bracket here that matches the class open bracket because the closing bracket from the template will be used when the code is plugged into the template.

 



Brian - Wednesday, September 8, 2010 7:29 PM:

Thanks for the response.

I got a bit further by putting the .dll in another directory under the ..Innovator/server/bin directory and referencing that in the  method-config.xml.

Innovator loads correctly now.

When I try to use the class in the .dll I get the following error:

"Could not load file or assembly 'BOMTools, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null' or one of it's dependencies. The system cannot find the specified file."

Since it has found the file name "BOMTools" and the version etc, all of which is information that is part of the file properties I have to assume that the system can find the .dll file that I have created.

OK. It is all to do with the Global Assembly Cache.

Once I added the .dll to the GAC using gacutil.exe it works as expected.

Interesting trick you have explained there.

Thanks again for your answer.

Cheers,

Brian.