G
Guest
Hi all,
I have test application written in C# from which I am trying to dynamically
invoke a DLL. I have two dll's the only difference being one is written in C#
and the other in VB.NET. The test application is able to sucessfully invoke
the dll written in C#. However when attempting to invoke the VB.NET version
of the dll the following error message occurs:
Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Paramater name: Type at System.Activator.CreateInstance(Type type, Boolean
nonPublic) at ConsoleApplication1.Program.Main(String[] args ) line 30.
Would anyone have any ideas why this is occuring? any help / comments
greatly appreicated (please see source code below).
TEST APPLICATION
============
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Reflection;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string className = "proclaim";
string enServer = "http://gis/mcity";
string enXML = "100.xml";
//string className = "enIntegration";
string appdll = className + ".dll";
object i = null;
//use reflection to invoke the Translator component
// Load the generated assembly into the ApplicationDomain
Assembly asm = Assembly.LoadFrom(appdll);
Type mm = asm.GetType(className + "." + className);
object o = Activator.CreateInstance(mm);
//Invoke a non-static method with parameters
object[] par = new object[] { enServer, enXML };
i = (String)mm.InvokeMember("Translate", BindingFlags.Default |
BindingFlags.InvokeMethod, null, o, par);
Console.WriteLine(i);
}
}
}
C# version of DLL
==========
using System;
using System.Collections.Generic;
using System.Text;
namespace proclaim
{
class proclaim
{
public string Translate(string enServer,string enXML)
{
return "Success";
}
}
}
VB.NET version of dll
==============
Imports System
Imports System.Collections.Generic
Imports System.Text
Namespace proclaim
Class proclaim
Public Function Translate(ByVal enServer As String, ByVal enXML As
String) As String
Return "Success"
End Function
End Class
End Namespace
I have test application written in C# from which I am trying to dynamically
invoke a DLL. I have two dll's the only difference being one is written in C#
and the other in VB.NET. The test application is able to sucessfully invoke
the dll written in C#. However when attempting to invoke the VB.NET version
of the dll the following error message occurs:
Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Paramater name: Type at System.Activator.CreateInstance(Type type, Boolean
nonPublic) at ConsoleApplication1.Program.Main(String[] args ) line 30.
Would anyone have any ideas why this is occuring? any help / comments
greatly appreicated (please see source code below).
TEST APPLICATION
============
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Reflection;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string className = "proclaim";
string enServer = "http://gis/mcity";
string enXML = "100.xml";
//string className = "enIntegration";
string appdll = className + ".dll";
object i = null;
//use reflection to invoke the Translator component
// Load the generated assembly into the ApplicationDomain
Assembly asm = Assembly.LoadFrom(appdll);
Type mm = asm.GetType(className + "." + className);
object o = Activator.CreateInstance(mm);
//Invoke a non-static method with parameters
object[] par = new object[] { enServer, enXML };
i = (String)mm.InvokeMember("Translate", BindingFlags.Default |
BindingFlags.InvokeMethod, null, o, par);
Console.WriteLine(i);
}
}
}
C# version of DLL
==========
using System;
using System.Collections.Generic;
using System.Text;
namespace proclaim
{
class proclaim
{
public string Translate(string enServer,string enXML)
{
return "Success";
}
}
}
VB.NET version of dll
==============
Imports System
Imports System.Collections.Generic
Imports System.Text
Namespace proclaim
Class proclaim
Public Function Translate(ByVal enServer As String, ByVal enXML As
String) As String
Return "Success"
End Function
End Class
End Namespace