|
I have a main form class that I'm writing in MC++ and I have an options form that's written with C#. The problem: I have an Options class (written in MC++, not the form) that holds all the options. What I want to do is have a static Options class in the main form (MC++) and a static method to return that class. In the options form I want to be able to call this static method in order to retrieve the options. I'm coming across a similar problem I had earlier (http://www.codeproject.com/script/comments/forums.asp?msg=597331&forumid=3785#xx597331xx[^]). I can't reference the form in any way from the C# form. I don't want to have to compile the entire MC++ project as a dll and I don't want to move the main form out into a different project. I would like to know if there's some way I can simply export this one function so that I can use it in my C# form without having to change mountains of code. Thanks for reading my rambling post, and thank you to anyone who can help.
- monrobot13
|
|
|
|
|
I tried to run my code and somehow this error message display:
gecko10:> prof callproc1.pixie callproc1.Counts >profile.pixie
Assertion failed: LSYMHEADER(ldptr)->pcfd = (pCFDR)calloc(cbCFDR, LPHDR(ldptr)->ifdMax), file ../../libodebug/ldfcn.c, line 582
Where is ldfcn.h/ldfcn.c ? What caused this problem?
I read the man page for ldfcn but that does not tell me much.
thanks in advance.
db
|
|
|
|
|
Is there any tool that does Automatic doc generation like in C# but for MC++ ?
Jonathan de Halleux.
|
|
|
|
|
Throw exception when start:
TypeLoadExeption: Can't find type: _IMAGELIST from assembly.....
Why?
|
|
|
|
|
This actually doesn't have anything to do with WTL. It's an incomplete definition in the PSDK. Try adding the following definition:
struct _IMAGELIST{};
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Hi guys,
I have been tasked with developing the new version of our web-based application, and my technology of choice for this is the .NET environment, primarily using managed C++.
The current application is ASP-based, althought his fact is not of particular interest to my request. In previous projects I have used ISAPI as a means of generating HTML content through Internet Information Server, and connecting on the server side to an ATL Service which is running independently of the web server. Essentially, the ATL service contains a single COM object that all other processes use by creating a proxy object which then interfaces with the singleton object. This service runs as an .exe.
I have written most of the objects as __gc classes that are exposed in a Managed .NET extension. I have hit the point now, where I want to have a singleton __gc class running in an .exe and for it to be accessible from an ISAPI extension.
I've trawled through many parts of MSDN, though not conclusively. I am trying to work out just how code in an ISAPI DLL, during a HTTP request, can pass on this call to the __gc ApplicationServer class residing in an EXE.
I'm not yet at the point of banging my head against the wall, but close, and any pointers on the way to do this would be appreciative. I haven't done so much as to prevent a slight redesign on the application front, so if that is what is required, so be it.
Many thanks in advance,
Ben Ashley
When it comes to maths and me, the wheel's going but the hamster's dead.
|
|
|
|
|
Sockets? I agree, that doesn't look like helpfull...
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I'm a new-comer to mc++, so I thought I'd start with something simple but useful. I was going to create a mc++ dll that I could link to from a vc++ app to make use of the native image conversion functions in the .Net framework (without moving an existing project to mc++). This was progressing nicely until I tried exercise some control over the compression used when encoding the new file. This requires use of the ImageCodecInfo class, which unfortunately can't be used in c++ (due to a contained jagged array ). Okay, so now I'm trying move the offending functions to a c# class library, so they can be accessed by the mc++ dll, and in turn by the vc++ app. The result is an app the crashes before the first line of my own code is executed. At this point, I know that there are three CWinApps being instantiated. The first is a _afxOleWinApp (presumably related to the c# dll), the second is mc++ dll, and the third is the vc++ app that the crash occurs in. The CWinApp constructor apparently wants to confirm that there's not already a thread before it creates a new one, but the mc++ dll's CWinApp is now showing up as the afxGetThread(). The constructor ASSERTs and everything grinds to a halt before it even starts. (If I remove the calls to the c# dll the problem goes away.)
This can't be a fundamentally flawed idea, right? I'm using the System.Drawing.Dll without any problems. Can somebody at least confirm that this should work?
|
|
|
|
|
|
Thanks for the tip. I'm inclined to agree that this is the problem (or at least one of them). After applying their "solution", it just crashes someplace else (when creating an instance of the class in the C# class library). As experiments go, I think I've had just about enough negative reinforcement to convince me that this isn't a wise use of my time. Maybe my luck will change.
Thanks again.
|
|
|
|
|
Hi.
I have written a small program in c++, that is to be executed when the user logs off from the computer. The program is triggered by the User Logout event (this is set in the user policy in Novell ConsoleOne). The program is to write to a database, registring the users logout. The program works fine when I execute or debug it manually, but it's like it doesn't have time to finish or even start before it is preempted when the system shuts down. Since it is impossible to debug the program under logout it is hard to tell how far it gets before it is preempted. I have given the program top priority but that did not help.
Does anyone know what I can do so that the program is given time to finish at shut down?
Earlier we ran a similar program written in VB6 but for various reasons we wanted a new one and now the old one does not work since we moved up to Win-XP.
Thanks
/EnkelIk
|
|
|
|
|
If I understand what your saying, you might look at OnQueryEndSession. I don't know about XP, but NT4 sends this to all the running apps at shutdown, so they can clean up and exit gracefully. It sounds like the default handler is closing your app out from under you.
Hope that helps.
|
|
|
|
|
Thanks.
It seems like the application is never allowed to start once the logout process has started on XP (which was apparently not the case under NT4). So I guess I have to make an app that starts att login and runs the whole time the user is logged on and finally does the work it is intended to just before it is shut down. Of course the app can not be allowed to take any cpu while waiting to be shut down.
Do anyone have a better idéa or can you recommend any articles or similar on the subject? How do I best implement the application? I haven't really implemented any event controlled applications in C++ before (appart from forms and console applications, but I can't have a form or console open and visible in this case).
Thanks
/EnkelIk
|
|
|
|
|
I'm trying to use an existing COM object from within .NET and am having problems passing a parameter than used to be of type VARIANT.
I have a COM interface, IScanner with the following method:
virtual HRESULT __stdcall GetOptionDetails (
/*[in]*/ long lOption,
/*[in,out]*/ VARIANT * pVarBuffer,
/*[out,retval]*/ long * plResult );
where the variant, pVarBuffer, will contain one of a variety of structures, including:
struct IMAGE_OPTION_DETAILS
{
long lSequenceNumber;
long lGreyScaleSupported;
long lVResolution;
long lHResolution;
long lBitDepth;
};
The following code shows how the structure was previously converted to a variant and passed to the interface:
void GetUdtRecordInfo(const TCHAR *tszName, IRecordInfo** ppRecInfo)
{
// Use Macro for easier unicode conversion
USES_CONVERSION;
ITypeLib FAR* pITypeLib;
ITypeInfo FAR* pITypeInfo;
HRESULT hr = LoadRegTypeLib(LIBID_PSCLASSICLib, 1, 0,
GetUserDefaultLCID(), &pITypeLib);
if (hr != S_OK)
THROW_ERROR("Failed to load type library");
// Retreive the IRecordInfo from the ITypeInfo interface for the first (and only) occurance
// of the type in the type library
USHORT nFound = 1; // number of occurances to look for
MEMBERID mID[1]; // array to store the MEMBERID of the type. Must be same size as nFound
hr = pITypeLib->FindName(T2OLE(tszName), 0, &pITypeInfo, mID, &nFound);
if (hr != S_OK)
THROW_ERROR("Failed to find the name of UDT.");
hr = GetRecordInfoFromTypeInfo(pITypeInfo, ppRecInfo);
if (hr != S_OK)
THROW_ERROR("Failed to get the Record Info of UDT");
// Release interfaces
pITypeInfo->Release();
pITypeLib->Release();
}
void ConstructRecordVariant(IRecordInfo* pRecInfo, LPVARIANT pVariant, void* pStruct)
{
VariantInit(pVariant);
V_VT(pVariant) = VT_RECORD | VT_BYREF;
V_RECORD(pVariant) = pStruct;
pVariant->pRecInfo = pRecInfo;
}
int _tmain()
{
IMAGE_OPTION_DETAILS details;
VARIANT var;
IRecordInfo* pRecordInfo = NULL;
CString sTypeName = "IMAGE_OPTION_DETAILS";
void* pStruct = &details;
// Construct the VARIANT data structures for the detail, in and out data.
GetUdtRecordInfo(sTypeName, &pRecordInfo);
ConstructRecordVariant(pRecordInfo, &var, pStruct);
// now we make the call to the COM interface
HRESULT = pIScanner->GetOptionDetails(IMAGE_FRONT, &var);
return 0;
}
In DotNet, the COM object is wrapped into a class with the above method converted to:
public int GetOptionDetails(int lOption, ref object pVarBuffer);
My question is how do I pass the converted version of the above structure to this method? I tried the obvious
ScannerClass * scanner = new ScannerClass();
IMAGE_OPTION_DETAILS details;
Object* obj = __box(details);
scanner->GetOptionDetails(
SCANNER_OPTIONS::IMAGE_FRONT,
&obj);
but this failed with:
"A first chance exception of type 'System.ArgumentException' occurred in PSTest.exe"
"Additional information: The specified record cannot be mapped to a managed value class."
Any help would be much appreciated!
Mike.
|
|
|
|
|
Hi all
I have an MFC class named CCoordWnd derived from CWnd. Now I'm porting this
class to .Net.So,I started with deriving from class
System::Windows::Forms::UserControl.
My MFC class CCoordWnd have overloaded constructors like these.
CCoordWnd(unsigned int cnum,CCoordWnd **myptr);
CCoordWnd(CCoordInterface *cip,CCoordWnd **myptr);
CCoordWnd(CCoordInterface *cip,unsigned int cnum,CCoordWnd **myptr);
and a member variable like this.
CCoordWnd ** m_myptr
Can anybody help me how can I implement these functionality in ManagedC++ environment.This is very urgent work for me.Please help me.
Thanks in Advance
Regards
Krishna
|
|
|
|
|
Here's the problem I'm facing: I have a hierarchy of classes:
class button;
class bitmap_button : public button;
class text_button : public button;
Now I want to wrap this is managed c++. How should I do this ?
Jonathan de Halleux.
|
|
|
|
|
Probably something like:
class __gc managed_button {button* bt_;...};
class __gc managed_bmp_button : public managed_button {bitmap_button* bmpBt_;...};
|
|
|
|
|
|
Is it possible to use a form written in C# in my MC++ app? I don't want to have to create the form programaticaly because it has quite a few controls on it. I added a Windows Form project to my solution and created the form, but I've no idea how I reference it in my MC++ app. I tried simply using Namespace::Classname , but that failed. Would I have to compile the form into a dll so I can reference it? If so how would I do that?
Thanks for the help.
- monrobot13
|
|
|
|
|
It would have to reside in a dll. You would just compile it as you would a normal dll. You could either reference it with a project reference, or with a reference to the dll binary.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Thanks for the reply. I acutally did get it working compiling it as a dll, but I have another question now. In order for it to work I have to copy the dll to the same directory that my exe excutes in. This is a royal pain and I know it's the wrong way to do it. I want to know how I can get the exe to use the dll from the location the dll is build to or how I can automatically have VS.NET copy the dll to the exe directory when it's built.
Thanks again.
- monrobot13
|
|
|
|
|
Well, I don't know about VS.NET, but I use SharpDevelop, and it allows you to specify scripts to run before and after a build.
Another thing you could do is to change the output directory to either the same directory as the exe, or a subdirectory under the exe directory, named the same name as the dll (w/o the ".dll" part).
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I'll see what I can do. Thanks for the help.
- monrobot13
|
|
|
|
|
I'm new to this myself, but isn't that what the
#using <drive:\path\filename.dll>
syntax is for?
|
|
|
|
|
In the VS.NET environemnt, right click your project and select "Properties", this will bring up the property dialog for that project.
Expand the "Build Events" leaf, and then select the "Post-Build Event" item.
In the Command Line box, enter something along the lines of:
copy "$(TargetPath)" ..\bin\debug\
Where ..\bin\debug (just taken from one of my projects) is the fully-qualified or relative path to where you want the file to be copied after successful compilation/linking. Note that in my example, I have separate output directories for debug/release builds and so copy to different directories. You may just have one directory for both configurations, and if so should select "All configurations" from the "Configuration" drop-down prior to entering the line above.
Hope that helps.
Ben
--
When it comes to maths and me, the wheel's going but the hamster's dead.
|
|
|
|