c++ cli - C++/CLI cannot access native member from different assembly -


i have c++/cli dll have source code cannot modify , have own dll want access member variable:

assembly 1 (cannot modified):

public ref class { public:     int m_iinteger;     someclass* m_ppointer; }; 

assembly 2 (own):

a^ a; int = a->m_iinteger; // no problem someclass* x = a->m_ppointer;  // c2248 

the problem compiler shows error:

error c2248: 'a::m_ppointer' : cannot access private member declared in class 'a'

the "object browser" shows:

public someclass* m_ppointer member of a

is there way access native public member different assembly?

i'm using visual studio 2012

edit: class "someclass" defined in native dll (which cannot modify too)

edit 2: have found solution. not nice works:

system::reflection::pointer^ ptr = (system::reflection::pointer^)typeof(a)->getfield("m_ppointer")->getvalue(a); someclass* result = static_cast<someclass*>(system::reflection::pointer::unbox(ptr)); 

all native types private default (in terms of managed accessibility outside assembly). so, though listed public, since type someclass private, makes inaccessible. can change prefixing the someclass definition public (if can modify someclass source code). or, if can't modify someclass source code, can modify code within dll, can use pragma:

#pragma make_public(someclass) 

that said, based on description sounds cannot modify assembly1 @ all, in case out of luck.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -