pls explain fault Type.IsGenericParameter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

base {System.SystemException} = {"Method may only be called on a Type for
which Type.IsGenericParameter is true."}

I have created a simple DLL.

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

namespace foonamespace
{
public class foo : HeatDrivers.Ifoo
{
public string testfoo(string testme)
{
return testme + "been tested";
}
}

When I try to load the assembly I get a number of errors which seem to
bubble up -> base {System.SystemException} = {"Method may only be called on a
Type for which Type.IsGenericParameter is true."}

What does it mean ? I cant follow the MSDN site to know what I should have
included if anything. I did extract an interface & build a DLL from that
extraction, BUT would that change anything ? Thanks
 
andrewcw said:
base {System.SystemException} = {"Method may only be called on a Type for
which Type.IsGenericParameter is true."}

I have created a simple DLL.

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

namespace foonamespace
{
public class foo : HeatDrivers.Ifoo
{
public string testfoo(string testme)
{
return testme + "been tested";
}
}

When I try to load the assembly I get a number of errors which seem to
bubble up -> base {System.SystemException} = {"Method may only be called
on a Type for which Type.IsGenericParameter is true."}

What does it mean ? I cant follow the MSDN site to know what I should
have
included if anything. I did extract an interface & build a DLL from that
extraction, BUT would that change anything ? Thanks

Hi,

You'll have to provide a bit more information here, what do you mean
by "When I try to load the assembly"?

Load it how? Using reflection? If so, can you post your code?
 
Tom,

Thanks for asking/replying MSDN just dumped my reply so I will enter it
again.
Yes - I am loading the DLL by reflection ( I have to late bind ). I have a
question that

might relate -

1. with the soluton HeatDrivers, I create the simple DLL.
2. I used VS 2005 to extract an interface.
3. I compiled the interface as a DLL with name interfaceFoo.dll.
4. I added a reference to interfaceFoo.dll then compiled that assembly as

HeatDrivers.DLL
5. I then added a reference to interfaceFoo.dll to the code TMSHeat2.exe
below that will

try to late bind the HeatDrivers.DLL.
6. But : I cant see any methods exposed from the interfaceFoo.dll if I
click on the
object browser. And if I try adding using HeatDrivers; with the rest of the
using
statement, it does compile, but I dont see any type ahead feature for
HeatDriver as if something is wrong. But TMSHeat2 tries to load the
assemblies but the objects are not exposed - and I see the
Type.IsGenericParamter fault bubbled up.

Here's the source code. My head is getting very confused at to what I am
supposed to do and see. Thanks

private void btnHEATDLL_Click(object sender, EventArgs e)
{
cdlg.Title = "select the DRIVERS.DLL";
cdlg.Filter = "*.dll|*.dll";
cdlg.FileName = "";
cdlg.ShowDialog();
string HeatDLLPath = cdlg.FileName;
if (HeatDLLPath.Length > 0)
{
LoadAndTest(HeatDLLPath);
//btnHEATDLL.Enabled = false;
}
}

private void LoadAndTest(string heatDriversPath)
{

try
{
Assembly a = Assembly.LoadFrom(heatDriversPath);
Type[] types = a.GetTypes();
foreach (Type typ in types)
{
// if I have reference for the interface I should be able
to find the

method ?
// MethodInfo mi = typ.GetMethod(someMethod);
//txtShowData.Text+= CartInfo.ExecRev;
mi.Invoke(0,null);

}
}
catch (TargetInvocationException ex)
{
MessageBox.Show(ex.InnerException.Message);
}


}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top