Click here to Skip to main content
11,934,443 members (55,032 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# MFC

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?

Posted 25-Jun-12 22:08pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

this link [^]might help you!
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 26 Jun 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100