473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DLL load should be easy, but errors

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
Jul 3 '07 #1
2 2256
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]
- mv*@spam.guard.caspershouse.com

"andrewcw" <an******@acw.comwrote in message
news:30**********************************@microsof t.com...
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

Jul 3 '07 #2
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]
- mv*@spam.guard.caspershouse.com

"andrewcw" <an******@acw.comwrote in message
news:30**********************************@microsof t.com...
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


Jul 3 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Shabam | last post by:
A web application of mine developed using C# + MS SQL runs fine normally. However when I stress test it with a load testing software (using about 60 simultaneous users) some instances start...
4
by: Jake Lewis | last post by:
I have an HTML page that loads fine including the .js file <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <script...
4
by: kunle Balogun | last post by:
on my home page, there is a frame that serves as a timetable for each day, i do i make this frame change automatically, assuming i have html files for each day? *** Sent via Developersdex...
7
by: DB_2 | last post by:
Hello, I was trying to load a comma-separated text file to a DB2 table. I believe I have the syntax rigt for the LOAD command. My first question is, how do you actually run it? It is not a...
1
by: hubristicbob | last post by:
hi, this might be an easy one to answer but I can't find the info on this. I am building an ASP.NET application that displays crystal reports from a network location. I can load any report on...
6
by: Tom | last post by:
Is there ANY easy way to close a MDI Child form in the middle of it's load? For instance, during the Load event I find a need to close the form (for whatever reason - maybe the user isn't ready for...
5
by: Engineerik | last post by:
I have a login form which I want to display with the showdialog method. When I do that the event handler for the load event does not run. If I use the show method the load event handler runs...
1
by: Sumanth | last post by:
We are using cli bulk loader to load data into db2. In some cases the rows get rejected and this is flagged as a warning allowing the program to continue. Is there any way to trap this warning,...
6
by: Rolandpish | last post by:
Hi there. I'm doing an application in C# 2005. I was used in VB6 to put code in Forms load event in order to initialize some values of the controls (grid values, text boxes values, label captions,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.