|
are you calling into question the bases of OOP ?
|
|
|
|
|
I have a base shared library written in C++/CLI. It contains a pointer to an instance of an unmanaged class. I would like to expose this pointer to my C++/CLI executable that is using the library. At first I wrote this simple code:
public:
static property DataPointModel* DPModel
{
DataPointModel* get()
{
if( NULL == m_sharedPortsContainer )
{
DeserializeModel();
}
return m_sharedPortsContainer;
}
}
The DataPointModel class is actually implemented in an unmanaged library.
It appears that the compiler hides this function to all external libraries because it exposes an unmanaged pointer. Is there any way to get around this so that I can access this pointer?
-- modified at 17:51 Thursday 16th March, 2006
|
|
|
|
|
static property IntPtr DPModel
{
IntPtr get()
{
if( nullptr == m_sharedPortsContainer )
{
DeserializeModel();
}
return m_sharedPortsContainer;
}
}
I haven't tested this, but I believe it might work. You will have to cast, the returned value to your DataPointModel*, however.
|
|
|
|
|
First of all, this is the (Managed) C++/CLI Forum! You may have better luck posting in the Visual C++ Forum.
|
|
|
|
|
Alright, im working on a Plugin script in my application.
Every plugin got saved in a seperated Dll with a main class:
public ref class Plugin : public PluginInterface::IPlugin
IPlugin is a abstract class with some basic info like Name, Date, Descryption and a few virtual methods, Initialize and so on.
Now my load function:
void cPlugins::AddPlugin(System::String ^FileName)<br />
{<br />
Assembly^ PluginAssembly = Assembly::LoadFrom(FileName);<br />
<br />
for each (Type^ PluginType in PluginAssembly->GetTypes()){<br />
if (PluginType->IsPublic){<br />
if (!PluginType->IsAbstract){<br />
Types::AvailablePlugin^ NewPlugin = gcnew Types::AvailablePlugin();<br />
NewPlugin->Instance = dynamic_cast<IPlugin^>(Activator::CreateInstance(PluginAssembly->GetType(PluginType->ToString())));<br />
<br />
if ((NewPlugin != nullptr)&&(NewPlugin->Instance!=nullptr)){<br />
NewPlugin->AssemblyPath = FileName;<br />
NewPlugin->Instance->Host = this;<br />
NewPlugin->Instance->Initialize();<br />
<br />
if (!this->AvailPlugins)<br />
this->AvailPlugins = gcnew Types::AvailablePlugins();<br />
this->AvailPlugins->Add(NewPlugin);<br />
}<br />
}<br />
}<br />
}<br />
}
or at least, code above is something like that. i tried to many different things. The definition of AvailablePlugin is like this,
public ref class AvailablePlugin<br />
{<br />
public:<br />
IPlugin^ Instance;<br />
String^ AssemblyPath;<br />
};
Now, for some or other reason, He wont give me a valid class. << Means, that the when i do a typecheck, he just says its a total different type. dynamic_cast<iplugin^>(Activator::CreateInstance(***)) wont agree with it.
How can i make this work? can anyone help?
Thanks already
|
|
|
|
|
Is this line correct?
NewPlugin->Instance = dynamic_cast(Activator::CreateInstance(PluginAssembly->GetType(PluginType->ToString())));
I can't see the type your are casting to? Probably a typo in your post. Wasn't it dynamic_cast < type-id > ( expression ) I guess you are using <IPlugin^>, don't you?
|
|
|
|
|
yes i am, as i already said, that piece of code is all messed up
|
|
|
|
|
I every one,
I want to know the maximum characters a String type can contain . 256 characters or more ?
|
|
|
|
|
|
Nemanja Trifunovic wrote: More
you couldn't answer more precisely on what the guy asked
|
|
|
|
|
as opposed to "your in the wrong group,
your in the wrong group"
|
|
|
|
|
I am feeling a little hate here! Nevertheless, the "prime directive" is to post your questions in the correct forum. However, we do need to use a little tact in informing someone of the "prime directive".
|
|
|
|
|
No hate... And it wasn't directed
at you, as your help is invaluable
to me and to others I'm sure.
Seems some just live to tell others
they've posted in the wrong group.
Group is quite, maybe we could just
start posting the managed answer to
whatever question was asked in
addition to telling the OP the error
of their ways.
Cheers,
Paul
|
|
|
|
|
I understand! I guess doing that is an easy way to increase your number of posts!
|
|
|
|
|
I sorry to post my messsage in a wrong group . But I don't know where is the accurate group for my message ?
-- modified at 2:13 Thursday 16th March, 2006
|
|
|
|
|
pardon ?
what the problem ?
i sincerely don't understand your intervention...
what does that mean ?
and how does it relates to me ?
|
|
|
|
|
Ok . It's more . But how much exactly ? can I set 4096 characters to a String ?
|
|
|
|
|
A 4096-character string wouldn't be a problem. You have a lot of room to work with? Just remember that the string-type does not mutate. Everytime you make a change, .NET creates a new instance with the change. There may be exceptions to this but a string is pretty much immutable. Of course, StringBuilder is mutable but it has its own overhead.
|
|
|
|
|
Since the String.Length property's type is Int32, it might be 2,147,483,647. Using large strings, can lead to a HEAP of trouble!
-- modified at 17:58 Wednesday 15th March, 2006
|
|
|
|
|
HEAP of trouble...
|
|
|
|
|
I'm testing my parallel port with the Borland C 5.5 compiler:
.....
.....
.....
while(!kbhit())
{
int data;
data=(inp32)(PORT+1);
gotoxy(3,10);
printf("Data available in status register: %3d (Decimal), %3X (hex)\n", data, data);
printf("\n Pin 15: %d",(data & 0x08)/0x08);
printf("\n Pin 13: %d",(data & 0x10)/0x10);
printf("\n Pin 12: %d",(data & 0x20)/0x20);
printf("\n Pin 11: %d",(data & 0x80)/0x80);
printf("\n Pin 10: %d",(data & 0x40)/0x40);
delay(10);
}
When I compile the program, it gives the following error:
Error: Unresolved external '_delay' reference from location
What is the use of delay(10) and gotoxy(3,10) in the program? Please advice.
Thank You
-- modified at 10:43 Wednesday 15th March, 2006
|
|
|
|
|
I have compiled a VC6.0 project under VS2005 and it compiles fine but when I try to run it on a machine that doesn't have VS2005 installed it comes up with:
"This application has failed to start because the application configuration is incorrect. Reinstalling the apllication may fix this problem."
So I guess that a single executable is no longer enough. What else do I need?
Any help is greatly appreciated.
I'm pretty sure I would not like to live in a world in which I would never be offended.
I am absolutely certain I don't want to live in a world in which you would never be offended.
Dave
|
|
|
|
|
provides the correct dlls with your application...
ps: did you notice that you were writing in a managed C++ forum ?
your question seems to have nothing to deal with MC++ code as it comes from VC6. so, next time, please post on the correct forum. thanks
|
|
|
|
|
Thanks - how do I determine which DLLs it needs?
re P.S.
Which forum would you recommend? Is this a problem with managed C++? .NET framework? Soapbox?
I couldn't decide so I took a shot at the one I thought might have people responding who have run into this problem before.
I'm pretty sure I would not like to live in a world in which I would never be offended.
I am absolutely certain I don't want to live in a world in which you would never be offended.
Dave
|
|
|
|
|