Re: DLL load should be easy, but errors



Thanks for the reply. The only thing missing from the code I gave was the
dialog to find the path to both DLL's. But I cant load even the simple DLL I
gave without inner errors. I replaced the winodws diagnostic with a quick
console app as shown. Just supply the exe with the path to the DLL I showed.

Here's the console app code ( no binding or reference in the console
project ) :

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;

namespace testDLLLoad
{
class Program
{
static void Main(string[] args)
{
if (args.Length>0)
{
string heatDriversPath = args[0];
if (File.Exists(heatDriversPath))
{
Assembly a = Assembly.LoadFrom(heatDriversPath);
Type[] types = a.GetTypes();
foreach (Type typ in types)
{ // check typ and find all the errors
MethodInfo mi = typ.GetMethod("CartInfo.ExecRev");
mi.Invoke(0, null);
Console.WriteLine(" ??? what now ???" + mi.ToString());
}

}
}

Console.ReadLine();
}
}
}







--
Andrew


"Nicholas Paldino [.NET/C# MVP]" wrote:

Can you post a complete example which details the problem?

Also, I would recommend using interfaces. While all of your methods
might be static, there is no reason you can't create an object which will
make the calls on the static method. This will help with your code, and
make abstracting out the provider (HeadDrivers.dll) a little easier.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"andrewcw" <andrewcw@xxxxxxx> wrote in message
news:30AB4251-7794-4AD1-A64E-35F240A316C1@xxxxxxxxxxxxxxxx
here is a DLL I need to mimic because the application does not connect to
real hardware depending on where the application runs ( it runs in a
simulation mode ).

The application ( C#.exe ) -> HeatDrivers.DLL ( the hardware one )
and
application ( C# .exe) -> HeatDrivers.DLL ( has a restricted simulation
stub
). Also I should note these are static classes

By an input file I would redirect the application to load the applicable
DLL
( locations are different ). Without using an interface class I called /
loaded each DLL - althought I could see all the classes/methods the load
was
flawed, because an internal error was generated. this is the simplified
DLL :

using System;
using System.Collections.Generic;
using System.Text;

namespace FTEE.HeatDrivers
{
public static class CartInfo
{
public static string ExecRev
{
get
{
string _ExecRev = "TMS Simulation stub";
return _ExecRev;
}
}
}

}

This is the calling piece from the EXE :

Assembly a = Assembly.LoadFrom(heatDriversPath);
Type[] types = a.GetTypes();
foreach (Type typ in types)
{
// ERRORS here ! < why is that ?? >
'typ.DeclaringMethod' threw an exception of type
'System.InvalidOperationException'
'typ.GenericParameterAttributes' threw an exception of type
'System.InvalidOperationException'
'typ.GenericParameterPosition' threw an exception of type
'System.InvalidOperationException'
}

Again Thank you for you effort & time
--
Andrew



.



Relevant Pages

  • Re: File or assembly name XXX, or one of its dependencies, was not found
    ... I'm catching the exception mentioned previously. ... the other forms load fine. ... > to load a form from a DLL: ... > at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence ...
    (microsoft.public.dotnet.languages.vb)
  • FileNotFoundException using Excel 97 interop in C# Windows Application.
    ... One of there dll:s uses Excel 97 interop dll to parse excel Workbook. ... Application loads these dll:s by iterating through files in certain directory and tries to load assembly ... catch (Exception ex) { ...
    (microsoft.public.dotnet.framework.interop)
  • Re: How to find whether dll loaded in process is causing error
    ... You can try to find out the load address by using some tool like the ... you can find out which dll caused the exception. ... > Created a stress test tool which load the instance of IE and Keep hitting the Different Url after the specified interval of time ...
    (microsoft.public.vc.debugger)
  • problem with using dll in fortran
    ... using loadlibrary and it works fine till it encounters an exception. ... It handles them all till dll is ... however once i load the dll the settings are lost and system ... tht the dll doesnt load for the release version of the project. ...
    (comp.lang.fortran)
  • Re: Load Testing Errors
    ... There are many reasons an application might fail under load when it normally ... I notice your exception is occurring inside a DataView. ... from your request when you were expecting non-null values. ... One is a "Object reference not set to an instance of an object." ...
    (microsoft.public.dotnet.framework.performance)