|
What happens when you type in: MCMXLIV
|
|
|
|
|
wut is tat ?
nvm...whatever i also solved my problem,thk u guy all !!
|
|
|
|
|
Hello,
I have a special question on the Invoke Method of the MethodInfo class and maybe it will show to be a general question on assembly techniques. I am using Managed C++ bytheway.
My goal is to load a library dynamically (as a plugin) and just get a specific function. This is all working well as long as I keep it simple.
- I defined an interface class and all plugin classes derive from that one.
- Now, the function that I want to invoke needs 4 parameters of which 3 are standard .NET objects. The fourth however is my own type.
- If I invoke that function with the parameter array, I get an exception as soon as my type object is not NULL saying the typical "Object cannot be converted to target type".
At first, I had my data class definitions in the main applications and additionally made a library with the same classes, which was linked by the plugin, as the plugin needs the same data classes, of course. I figured, he might have trouble realizing that these are really the same types. So I put the classes into a separate library. Now, the main application AND the plugin link the SAME library. But seperately at different times, I guess.
Could this already be the problem? Or where else is the problem?
I also found something about "copylocal" related to similar problems, which should be set to "false". But I have no idea in which area this setting is to be made and if it will really solve the problem.
Further thought: in the common plugin-samples the thisObject for
mi->Invoke (thisObject,...) is created by
thisObject = Activator::CreateInstance (type);
This doesn't work for me either, as the class information I have is only the Interface which cannot be instanziated. The specific class definition is in the plugin. Is that related to my problem? If the invoke works anyway, I'm fine as it is.
Again: Invoking methods of the same plugin, that do not use my own classes cause no problems.
I would appreciate any help and hint. Maybe I am close or I am far off. I just don't know. My samples were all C# and too simple, so finally, I am lost.
Thank you very much in advance! If you need some code, I can provide that on Monday, when I'm back on my PC.
Thank you and have a nice weekend,
dawei
|
|
|
|
|
Does the directory containing the plugin assembly also contain the assembly in which your type is defined? Does it work if the main assembly, the plugin assembly and the library are in the same directory?
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
In fact, although I set the reference to the same dll within the project settings, a copy of the linked library is created in the plugin folder, which is different from the main applications folder. But the versioning of the libraries should be recognized as the same, shouldn't it?
(stupid question: 'assembly' stands for DLLs and EXEs in .NET, right?)
I will try putting everything into one folder, and I will tell you if it worked or not. The target of my project however was to keep the plugins in an extra folder. Would there be a way to achieve this?
You see I'm coming from the pure C++ originally and I did not yet fully absorbe the assembly management details, although I see it has many benefits.
Thank you and thanks again,
dawei
|
|
|
|
|
dawei.code wrote: But the versioning of the libraries should be recognized as the same, shouldn't it?
Yes, unless you don't build the main application and the plugin project together. A "Build Solution" command (assuming both of them are in the same solution) should take of this problem, if it is the reason.
dawei.code wrote: I will try putting everything into one folder, and I will tell you if it worked or not. The target of my project however was to keep the plugins in an extra folder. Would there be a way to achieve this?
Yes, there are plenty of articles in the internet, just Google for "C# Plugins", you can easily translate the idea to C++/CLI.
dawei.code wrote: 'assembly' stands for DLLs and EXEs in .NET, right?
Yes, but assemblies need not be .dll or .exes. .NET supports multifile assemblies (although VS .NET doesn't), which means you could have code and resources for a single assembly spread across modules.
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
Hi again,
keeping the DLLs together made it (of course I might say). So thank you very much. Fort the moment I can continue. Let's see what else will happen in that course. I also tried the copylocal=false advice, but this brought more problems than I want to take now.
Thank you again and best regards,
dawei
|
|
|
|
|
i've created one DLL (testlib) and i want to use it in my application as an array of its instances ...
i'm getting an exception as
'System.NullReferenceException'
plz consider the following code ..
//-------------------------------------------------------------------------
testlib::testlibControl *tmp1 __gc[];
for(int i = 0; i < strength; i++)
{
tmp1[i] = new testlib::testlibControl;
tmp1[i]->Location = System::Drawing::Point(x,y); //exception
tmp1[i]->Size = System::Drawing::Size(24, 29);
x += 30;
this->Controls->Add(tmp1[i]);
}
//-------------------------------------------------------------------------
Why does this code cause exception?
Thanks,
Kranti
|
|
|
|
|
Hi,
I might be wrong but most likely you forgot to initialize your array.
testlib::testlibControl *tmp1 __gc[];
// add the following
tmp1 = __gc new testlib::testlibControl*[strength];
for(int i = 0; i < strength; i++)
{
...
However with the new Syntax it should be something like this:
array<testlib::testlibControl^>^ tmp1 = gcnew array<testlib::testlibControl^>(strength);
Furthermore i do strongly recommend to use the new syntax, because it is far more easy to read.
best regards Tobias
|
|
|
|
|
ok .. i've made required changes as follows but still i'm getting the
same exception
testlib::testlibControl *tmp1 __gc [];
tmp1 = new testlib::testlibControl* __gc [10];
for(int i = 0; i < strength; i++)
{
tmp1[i]->Location = System::Drawing::Point(x,y); //exception
....
...
}
Thanks,
Kranti
|
|
|
|
|
Hmm,
is it correct that your testlibcontrol class is unmanaged?
I mean, as far as i know it should be like this if it's a managed one:
testlib::testlibControl __gc* tmp1 __gc [];
Though i suppose you have created a managed array of unmanaged testlibcontrol pointers? However you said that it is crashing on this line:
tmp1[i]->Location = System::Drawing::Point(x,y); //exception
Therefore it can be only one of the two things, either x or y have not been initialized (which is very unlikely) or your array is not properly initialized. IMHO it is related to the second one. Therefore I would suggest that you'll have a close look into your testlibcontrol class (constructor etc.) and the initialization of that array again. Furthermore you should step through your code with the debugger and check if it has really initialized an object of the type testlibcontrol here:
tmp1[i] = new testlib::testlibControl;
regards Tobias
|
|
|
|
|
hey,
thanks a lot .. this type of initialization worked for me ...
testlib::testlibControl *tmp1[] = __gc new testlib::testlibControl*[10];
tmp1[i] = new testlib::testlibControl;
tmp1[i]->Location = System::Drawing::Point(x,y);
tmp1[i]->Size = System::Drawing::Size(24, 29);
Thanks,
Kranti
|
|
|
|
|
How to write and read an object of user defined class into file.
|
|
|
|
|
this is called serialization.
i think that if you posted your question here, it's because you'd like to do it in Managed C++.
i don't have the solution, but there is certainly some articles about how to Serialize/Deserialize class instances.
|
|
|
|
|
I am using Borland C++ (v4.5) and trying to write a program to input output one byte to the parallel port. It used to be fairly easy prior to XP. I have seen various things on the web that are supposed to get around the hard bit of overriding XP's control over the port, e.g.
www.geekhideout.com/iodll.shtml
but I can't get them to work. I think I must be doing something wrong in the way I include the .h and .dll files into the project. What is the difference between starting an ordinary .cpp program and a project.
Can anybody offer me some advice please
Geoff
|
|
|
|
|
|
I am currently using Visual Studio 2003, I see that when I choose a new project for C++ I can not pick any project to develop on a mobile device. C# has this option.
Is it possible to build an application in C++ with managed extension (with \clr ) for mobile development? If so does anybody got a link or so to point me in the right direction?
Greetings,
Davy
|
|
|
|
|
hi everyone i have a project like that :
You are supposed to develop a garage system simulator. Possible system classes are car owner, car, garage, fee, payment.
Take into account the following assumptions:
1- A customer may take parking , washing, polishing services.
2- There is predefined parking fee list. Important point is to hold time chart for a car.
3- Washing service choices are outer or all.
4- Payment includes all services.
5- Manager should be able to check the numbers of car and the money. This report may be taken daily or for a duration.
please help.
if you write c++ code i will be so presuade. thanks a lot.
-- modified at 11:50 Tuesday 4th April, 2006
|
|
|
|
|
Sir,
You need to start writing your simulator application. While you are programming and you have a specific question on coding, please post your question here if you are using Managed C++ or C++/CLI. Otherwise, not too many developers are "nice" enough to write this project for you.
George
-- modified at 18:45 Tuesday 4th April, 2006
|
|
|
|
|
do your homework yourself 
|
|
|
|
|
Did you read this[^] before posting ?
-- modified at 5:08 Wednesday 5th April, 2006
Link corrected
|
|
|
|
|
ok guys, i will start my project and if i have a specific question i will ask it. thanks a lot. 
|
|
|
|
|
I`m writing a dll in C++ that uses managed extensions. Its purpose is to wrap a .NET library I wrote so that I can use it in an existing C++ project I have here.
All goes smooth, but I got some problems now calling a C# function of the dll that has an out parameter.
function definition in C#:
public enumMsgType DoYourThing(string sMethod, ref Single Cnt, out string outParam, string inParam)
my wrapper function is:
CMyWrapperObj::wrMessageType CMyWrapperObj::InvokeMethod( LPCTSTR sMethod, float& nNum1, CString& sOutParam, LPCTSTR sInParam)<br />
{<br />
return static_cast<CMyWrapperObj::wrMessageType>((*this)->InvokeMethod(sMethod, &nNum1, sOutParam,sInParam));<br />
}<br />
I get a build error on the sOutParam parameter:
MyWrapper.cpp(60) : error C2664: 'COMCaller::ManagedObj::DoYourThing' : cannot convert parameter 3 from 'CString' to 'System::String __gc *__gc * '
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
So I guess I need to call this function not with a CString parameter.. .I also tried a std::string variable to pass in the parameter list, but also that doesn^t work... It`s probably something obveous that I`m overlooking, but if you could point me to it I would be gratefull
Greetings,
Davy
|
|
|
|
|
why don't you use LPCTSTR parameter, or ever simple, System::String ?
|
|
|
|
|
LPCTSTR because the string isn^t a constant, it will get a new value in the .NET function that will be called.
System::String .. Since I don^t want to have any managed types in my header files I guess my mind didn^t get to that point.
Well thanks a lot, got the thing compiled now, I can now focus on the next issue!
|
|
|
|