|
May be you can post code, that giving error.
|
|
|
|
|
<br />
<br />
#include "stdafx.h"<br />
<br />
using namespace Microsoft::Win32;<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
<br />
rkey = Registry.CurrentUser;<br />
rkey1 = rkey.OpenSubKey("Software",true);<br />
<br />
RegistryKey rkey2 = rkey1.CreateSubKey("Tweety");<br />
<br />
rkey2.SetValue("Name","Tweety");<br />
rkey2.SetValue("Age",24);<br />
rkey2.Close();<br />
rkey1.Close();<br />
<br />
return 0;<br />
}<br />
Error Log
Im still learning 
|
|
|
|
|
Oh dear ! you are not using managed C++, I fear.
If you want to use this code in unmanaged c++, go to project properties-->configuration properties-->Project defaults-->common language runtime support and set it to commong language runtime support(/clr) .
Or better of starting new project with type VC++-->CLR-->CLR console application .
|
|
|
|
|
it wasn't giving me that option, although I did notice what you were talking about. so im just removed all of my sdk components and reinstalled my sdk. but also i do want to thank you and you helped allot.
|
|
|
|
|
It would be better, if know what project type you have used for creating this console application, If you had selected VC++-->CLR , error you have mentioned should not come at all. If its VC++-->win32 application , you need to select option I mentioned earlier.
Herboren wrote: i do want to thank you and you helped allot.
Its pleasure to help you.
|
|
|
|
|
case USER_NORMAL:
for each (String ^tempStr in arrTableUsers_NORMAL)
{
if (firstColumn == true)
sql += tempStr;
else
sql += ", "+tempStr;
}
return sql;
break;
case USER_POWER:
If i have enabled for each block in a switch statment, i get errors:
Warning 1 The type initializer for '<Module>' threw an exception. 0 0
Warning 2 The variable 'lstListUsers' is either undeclared or was never assigned. 0 0
Error 3 error C2360: initialization of '$S3' is skipped by 'case' label c:\projects\cddvdorganizer\cddvdorganizer\syntaxBuilder.h 379
can somebody please help, this is me a headaches.
|
|
|
|
|
bsaksida wrote: Error 3 error C2360: initialization of '$S3' is skipped by 'case' label
Modify your code like,
case USER_NORMAL:
{
for each (String ^tempStr in arrTableUsers_NORMAL)
{
if (firstColumn == true)
sql += tempStr;
else
sql += ", "+tempStr;
}
return sql;
}
break;
case USER_POWER:
|
|
|
|
|
Thanks, I woud newer thought about this solution, By the way:
Do you know how to fix the foolowing errors.
Warning 1 The type initializer for '<module>' threw an exception. 0 0
Warning 2 The variable 'lstListUsers' is either undeclared or was never assigned. 0 0
|
|
|
|
|
bsaksida wrote: Warning 1 The type initializer for '' threw an exception.
Not sure about this. Might not be due to code shown by you.
bsaksida wrote: Warning 2 The variable 'lstListUsers' is either undeclared or was never assigned. 0 0
Again, this warning doesn't seem to be due to shown code. Where it takes you in the code ? if you click on them.
|
|
|
|
|
It doesn't take me anywhere.
In my solution i added a project(dll) with name ListViewFlickerFree.
declared as lstListUsers.
ListViewFlickerFree ^lstListUsers;
When i had it inside my main project. Sometimes my Design View printed out a an error, instead form. Even if source code didn't change. Sometimes to get it back i had to manualy delete all autogenerated files. Not yust using clean. but also delete .ncb, .suo files
|
|
|
|
|
prasad_som wrote: bsaksida wrote:
Warning 1 The type initializer for '' threw an exception.
Not sure about this. Might not be due to code shown by you.
Fixed that by deliting .ncb and .suo files.
prasad_som wrote: bsaksida wrote:
Warning 2 The variable 'lstListUsers' is either undeclared or was never assigned. 0 0
Again, this warning doesn't seem to be due to shown code. Where it takes you in the code ? if you click on them.
Fixed that:
I had to use batch Build to build the second project(dll) as debug and release
|
|
|
|
|
|
Hi, recently I've found this article: State Pattern in C++ Applications. I've got some questions regarding it.
1. I understand the state can change to another from the state itself. And I saw in the demo there's a forward declaration of GameState in GameStateManager. Is this a good practice?
2. If in each state there's a substate, what should I do? Eg. in Opening there's the AttrackState, CreditState, DemoState, etc.
3. If in each state there's an instance to the same pointer of object (e.g. the GameData pointer of object), what should I do?
Thanks.
"I live for my dream. And my dream is to live my life to the fullest."
|
|
|
|
|
Benang wrote: Hi, recently I've found this article: State Pattern in C++ Applications. I've got some questions regarding it.
1. I understand the state can change to another from the state itself. And I saw in the demo there's a forward declaration of GameState in GameStateManager. Is this a good practice?
2. If in each state there's a substate, what should I do? Eg. in Opening there's the AttrackState, CreditState, DemoState, etc.
3. If in each state there's an instance to the same pointer of object (e.g. the GameData pointer of object), what should I do?
You might want to direct your questions to the article author. You can post a message at the bottom of the article...
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
Ah sorry about that. Didn't realized it. Thanks.
"I live for my dream. And my dream is to live my life to the fullest."
|
|
|
|
|
No worries
"That's no moon, it's a space station." - Obi-wan Kenobi
|
|
|
|
|
I am developing an application, and in mine solution there are 3 projects. One of them is MySql Connector 5.02, Witch is build in c#.
I am developing in c++/cli. mysql connector uses Mysql.data.dll
But i wan't to publish my project as opensource, and is server/client based, so i used a lot of #define dirrective to compile with password and other setting, needet to connect to server. When someone woud see a code, he coud get an idea to modify yust mysql connector, to get password, so i came here to ask a specific question. Is it possible to use seperate project to include in another project without using dll, but to include directly to exe? And without any special port to my project. (like inserting with asm or modify to c++/cli)
|
|
|
|
|
i have array with 5 declerated items, but i wan't to add another.
I don't want to execute the code twice, yust first for count to see how many declerations is needed, secund time to declare array with n items, as counted before.
I don't like to use another array as predefine, to backup and redeclare first array with index+1 and then copy from temp array back.
I know it is possible in managed c++, but i am using c++/cli (With .NET framework 2.0) and i don't wan't to use with compiler /cli:old
|
|
|
|
|
Use the 'Resize' method of the Array class.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: VB to Python converter
|
|
|
|
|
Thanks, I yust needed that.
|
|
|
|
|
Hello,
I’m trying to send delegate to unmanaged code, so when the unmanaged class will catch an event it will execute the proper function in the managed class.
I used GCHandle::Alloc() to prevent from the GC to change the position on the heap and
Marshel::GetFunctionPointerForDelegate()to convert the delegate to unmanaged function pointer.
The main problem is that an error occurred while I tries to execute the function pointer in the unmanage code to the managed code I get that error.
“
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'D:\Dev\Test_TA.exe'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x79f1c189, on thread 0x910. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
“
Did anyone encounter this problem?
Is it a problem with the Marshel::GetFunctionPointerForDelegate()? Or with the GC?
Thanks,
|
|
|
|
|
|
Hi,
Thanks for your reply.
I already try that before, but it my case the program structure is little different.
The problem is that the program has 2 phases:
1. Managed class creates a delegate and sends it to unmanaged class which assigns it to a function pointer member.
2. The unmanaged class listens to events from other place and when a specific event occurred then the unmanaged class should call the function in the managed class.
(From the first phase)
Maybe there is no different between cases but I still get this error.
Thank you,
|
|
|
|
|
This is almost same case. The only difference that EnumWindows calls managed callback number of times inside of method, and keeping local delegate instance is enough. In your case you need to keep delegate as class member.
I think the problem is in function prototype. What is required unmanaged prototype and managed callback prototype?
In my program I use another method for managed callback - because I didn't know about this Marshal function when started to write it. Code fragments:
GCHandle gcHandle; // managed class member
// Constructor:
gcHandle = GCHandle::Alloc(this);
void* callbackPtr = GCHandle::ToIntPtr(gcHandle).ToPointer();
pUnmanagedClass->SetCallbackAddress(callbackPtr);
// Destructor:
gcHandle.Free();
Pass callbackPtr value to unmanaged class. This is simple unmanaged void* pointer, which allows to call managed class function when necessary.
// Unmanaged class calls managed class:
GCHandle h = GCHandle::FromIntPtr(IntPtr(callbackPtr)); // callbackPtr is passed from managed class
YourManagedClass^ pThis = (YourManagedClass^)h.Target;
pThis->CallbackFunction();
|
|
|
|
|
I still get the error
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'D:\Dev\Test_TA.exe'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x79f1c189, on thread 0x910. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
This error ocured when the function pointer in the unmanaged code call
to the function in the managed code.
In the managed code I uesd GCHandle::Aloc(this).
thanks
|
|
|
|