|
Thanks for replying.
But my problem persists.
Actually I have tried both ways. One using PInvoke & the other using Managed Wrappers. In both the approaches, I am able to enter the unmanaged function, pass data. But, moment I call the frame APIs or try using new, malloc etc it bombs throwing NullRefernceExcpetion.
In the console applictaion, I complied it using /clr.
I run it & it interacts with the framemaker perfectly.
Frame maker APIs are written in C/C++.
My objective is to call the Framemaker APIs from C#.
What is the best way to this ?
What i belive is that i can get a resoltuion if i m successful in migrating the EXE as a .Net Dll. But, I have tried both ways & I am not able to go ahead because of the issue.
I read it on the net that such exceptions could be raised by something called as Access Violations in the unmanaged code. But, I dont know how to resolve it.
|
|
|
|
|
Some suggestions:
I am unfamiliar with the Adobe Framemaker DLLs, but I'm guessing they are COM libraries. Generally, when you get a NullReferenceException, as you no doubt are aware, you failed to correctly instatiate the COM object or Interface that you must obtain (by calling Query Interface) in order use the method. In your code, you could handle the exception by outputting the exception to a message box or something similar.
malloc is deprecated in C++, and should NOT be used in .NET (although you can use the appropiate headers that define the malloc memory allocator) it is not recommended. Instead use the new operator to instantiate objects, and then -> pointer syntax to invoke methods.
If you are dealing with a COM type library, try using the TlbImp.exe that is included with the Framework SDK and the .NET Framework install. This utility will convert a type library into a .NET assembly that can be referenced directly in source code and used as if they were .NET Framework types. You can then examine the types, methods, and all associated elements in the IL Disassembler, which is a great help.
However, none of the above explains why your code would work in a managed console application, and why it would fail in (what I'm assuming is a managed forms application). I'm guessing that you are leaving out some critical piece of information.
|
|
|
|
|
I tried using ToolboxItem(false) in Managed C++, but it gave me a compiler error:
"error C3725: 'System::ComponentModel::ToolboxItemAttribute': cannot resolve attribute overload".
Please Help
Thank You
tomand
|
|
|
|
|
hi
i want to know what is difference b/w visual c++ and managed c++, is there is lot of difference b/w visual c++ and managed. any tutorial for managed c++.
ddd
|
|
|
|
|
Managed C++ is C++ that compiles to the common language runtime instead of native byte code. Disadvantages: it will be slower. Advantages: you can use the .NET framework to get support for things like regex. Stuff that could be an advantage, based on your point of view: garbage collection.
Managed C++ has not fared well in the marketplace. I don't use it, if I want MSIL, I write C#. If I want speed, I use C++.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I was trying to write the string object and ran into trouble. I'm getting run-time error. The run time error says: blah blah... the memory could not be "read".
I'm using MinGW g++ to compile this program. The program is actually much much longer but i deleted everything that used to be there so it is easier to figure it out.
The run-time error occurs inside of the c_str() function.
But it happens before leaving the substr() function (which calls the c_str() function)
The c_str() function works without generating runtime errors sometimes.
here is the output of my program:
in c_str(): string=this, was, a, test
before new char[18]
after new char[18]
after data is copied.
out c_str()
from main(): this, was, a, test
in substr:
new char[8]
after new char[8]
leaving substr
in c_str(): string=this, wa
before new char[8]
after new char[
and then the runtime error occurs.
So, basically, I get runtime error on the line of code that says:
tmpStr = new char[size]; (inside of c_str()), but why would new char[8] cause a runtime error?
It makes no sense to me everything looks correct to me its driving me insane.
Please help.
|
|
|
|
|
I think i screwed up and posted this message in the wrong section of this website. Maybe it should be under: ATL / WTL / STL
I know people really get upset when users like me do this, but now its too late. I appologize for the mistake.
|
|
|
|
|
I am taking C++ and does anybody know how to make a password code to read a encrypted password simple and easy.
Any suggestions would be helpful.
|
|
|
|
|
where do you hope to read it from ? Do you want to decrypt it, encrypt it, or both ? As you're asking in the managed C++ forum, the .NET framework provides a namespace full of cryptography APIs. As it seems you're 'taking C++', I assume you've asked in the wrong area, and your question relates to ANSI C++. If you could perhaps clarify where you want this password to come from and go to, and what you want to happen to it along the way, perhaps I can help you further.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
This may seem easy, but I swear I cannot find a simple answer.
I have a directory which I plan to make readable by all, but writtable only by Admin group. I need, whne I create files, with code, protect those files from being written by any except Admin. I would also like to make it readable by only Admin and an Operators group if possible.
Can someone give me a clue on what classes to use, and / or a pointer to a web site with an example.
TIA
|
|
|
|
|
I'm looking for a way to send a formated string to the printer using mc++. I have looked into MFC and it seems pretty in depth. Any advise would be greatly appreciated.
Thanks
|
|
|
|
|
MFC printing is easy. There are a couple of helper classes on this site, but just adding support with the wizard gives you the methods you need, you end up printing in your main onpaint method, from memory, and some other methods just set up the printer for you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How to Print a file By a program Using C++ Ver. Borland 5.2.
Please Send me a Function that prints a given file object.
Thank You.
Dohan
|
|
|
|
|
to print it in a file
void func()
{
// given object(file1)
fstream file1("pass.dat",ios::app|ios::binary|ios::in|ios::out);
file1.write((char*)&x,sizeof(x));
//x is an object
file1.close();
}
to output a file object
void func()
{
fstream file1("pass.dat",ios::app|ios::binary|Ios::in|ios::out);
file1.seekg(0);
file1.read((char*)&x,sizeof (x));
}
ushani
|
|
|
|
|
Hi Guys I have been banging my head against the wall for some time.Please Help...
I have downloaded an example in C#.NET and have made some conversion that have worked
in my C++.NET winform application. Does anyone have any ideas?
The last line does not work.......
// get the collection of sheets in the workbook
//C# example
// Excel.Sheets sheets = theWorkbook.Worksheets;
// This conversion works
Interop::Excel::Sheets *sheets = theWorkbook->Worksheets;
//C# example
// Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
// This does not work..it is looking for a
// error C2664: 'Interop::Excel::Sheets::get_Item' : cannot convert parameter 1 from 'int'
// to 'System::Object __gc *'
Interop::Excel::Worksheet *worksheet = (Interop::Excel::Worksheet*)sheets->get_Item(1);
|
|
|
|
|
Does anybody know how to call an executable from a C++ program
|
|
|
|
|
I think you call a method on the Process object.
|
|
|
|
|
I have 2 forms. The parent form has some text boxes that the child form populates. The child form pop up when the user chooses to enter information. how can i get the user input from the second form to the parent form? I tried setting the variable as public but it did not seem to help. Any suggestions? Thanks
|
|
|
|
|
Lagwagon56 wrote:
I tried setting the variable as public but it did not seem to help. Any suggestions?
I'd guess you set the text boxes to be public ? This is a bad idea for a number of reasons to do with good design, but the core issue is that once your form is closed, those text boxes no longer exist. You need to override the OnClose method, so that before the form closes, the text you want to retrieve is copied to some string variables, and then expose some get methods to return those strings after the form is closed.
BTW, this is the managed C++ forum, a question like this is better in the C++ forum, even if you use MC++ ( because it's not related to managed extensions ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus,
Thanks for the reply. I figured out a way to pass variables by creating a class that passes the information. I just pointed each from to it. Thanks again.
|
|
|
|
|
we need to control a web cam to take a poto in a speipic time
|
|
|
|
|
Ok,
Not C#,
Not VB,
Not using DirectX.
Using Visual C++ .net managed code, I havent found a way to play waves as
in the old Win API call PlaySound().
All the uses of importing winmm.dll such as:
[DllImport("winmm.dll")]
public static extern bool sndPlaySound(byte[] pbyte, int param);
are for VB or C#.
Any help in figuring this out would be greatly appreciated!
Scott
Old Windows App builder.
|
|
|
|
|
This might be TOO easy for you, but,...
The DirectX 9 SDK (Summer Edition, and I suppose the latest download), has a Managed Version of the DirectX 9 DLLs. You can view the contents of the assemblies in the IL Disassembler; which makes for almost effortless usage. Just reference the assembly with the #using directive and set the correct search path for the Visual C++ .NET include and reference files directories, and your Intellisense should show you everything.
But, if you actually WANT to do it the hard way,...
|
|
|
|
|
Thats not a dumb suggestion ursus I hadnt thought of those new DLLs... didnt think MS
would go to all that trouble when they were planning on changing the managed code and
C++ anyway.
I'll give it a try.
And as an aside, the easy way is my ALWAYS my favorite way! Especially when dealing with MS
compilers hehe.
Thanks again...
Scott
|
|
|
|
|