Click here to Skip to main content
15,039,021 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi
i made a dll in C# with Class Library project.
this dll has one function.
then i added this dll in an MFC project with Add Reference.
then i define a variable with type Mydll::Class1.
while this definition is placed in a function, there is no problem but when i want to define it as global or member variable of class i got an error.

the help offers this message:
You can only define CLR objects within function scope


is there any solution to define a global variable?

thanks
Posted

1 solution

this link [^]might help you!
   
Comments
Moharram 2-Jul-12 0:37am
   
this link is useful for COM base dll but my dll isn't COM base.
ThatsAlok 2-Jul-12 9:47am
   
I doubt you can achieve that in plain vanila way!. See you are trying to export class, which is not possible straight forward.

I See you are MFC programmer, have you heard about MFC extension library these DLL are only capable of exporting class without com support for rest COM is only way. otherwise you wrap you dll and provide plain method to export data

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900