|
|
hmm...never mind my last reply - i think I misread your post.
Maybe your native class could use a managed class object to handle
the event/delegate stuff.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Short questions: Can I include old C code?
So far I was used to have an extern "C" block around the corresponding include-instructions.
Is this still possible in C++/CLI, or does "managed C++" not allow any C code at all? At least the compiler tells me that the file I wanted to include cannot be compiled with /clr option.
|
|
|
|
|
Don Rolando wrote: Short questions: Can I include old C code?
Yes
Don Rolando wrote: So far I was used to have an extern "C" block around the corresponding include-instructions.
I don't know what you mean but I just added these, compiled and executed my project without error.
extern "C" int getfoo(){ return 12; }
extern "C" int getbar(){ return 14; }
int _tmain(int argc, _TCHAR* argv[])
{
System::Console::WriteLine("Mixed Mode Console (v 1.0)");
System::Console::WriteLine(System::String::Format("foo: {0}", getfoo()));
System::ConsoleKeyInfo ki = System::Console::ReadKey();
return 0;
}
led mike
|
|
|
|
|
I have these linker errors:
Error 9 error LNK2028: unresolved token (0A0000AA) "extern "C" unsigned int __stdcall MsiOpenDatabaseW(wchar_t const *,wchar_t const *,unsigned long *)" (?MsiOpenDatabaseW@@$$J212YGIPB_W0PAK@Z) referenced in function "public: cli::array<class System::String ^ >^" (?patchListing@Patch@@$$FQAMP$01AP$AAVString@System@@PB_W@Z) FormSearchFile.obj <br />
<br />
<br />
<br />
<br />
Error 13 error LNK2019: unresolved external symbol "extern "C" unsigned int __stdcall MsiCloseHandle(unsigned long)" (?MsiCloseHandle@@$$J14YGIK@Z) referenced in function "public: cli::array<class System::String ^ >^" (?patchListing@Patch@@$$FQAMP$01AP$AAVString@System@@PB_W@Z) FormSearchFile.obj
I tried to fix them by including msi.lib in the linker's additional dependencies but still it dosent work..
Why??
Could anyone help????
Som
|
|
|
|
|
I even tried Heath's blog..
http://blogs.msdn.com/heaths/archive/2005/12/15/504399.aspx
Still it doesnt work
Som
|
|
|
|
|
I am getting these two errors:
Error 2 error LNK2028: unresolved token (0A00007F) "extern "C" long __stdcall RegEnumKeyExW(struct HKEY__ *,unsigned long,wchar_t *,unsigned long *,unsigned long *,wchar_t *,unsigned long *,struct _FILETIME *)" (?RegEnumKeyExW@@$$J232YGJPAUHKEY__@@KPA_WPAK212PAU_FILETIME@@@Z) referenced in function "public: void __clrcall BuildPatch::findRegPatch(void)" (?findRegPatch@BuildPatch@@$$FQAMXXZ) FormSearchFile.obj FormSearchFile<br />
<br />
Error 6 error LNK2019: unresolved external symbol "extern "C" long __stdcall RegQueryValueExW(struct HKEY__ *,wchar_t const *,unsigned long *,unsigned long *,unsigned char *,unsigned long *)" (?RegQueryValueExW@@$$J224YGJPAUHKEY__@@PB_WPAK2PAE2@Z) referenced in function "public: void __clrcall BuildPatch::checkRegValues(struct HKEY__ *,wchar_t * const,wchar_t * const)" (?checkRegValues@BuildPatch@@$$FQAMXPAUHKEY__@@QA_W1@Z) FormSearchFile.obj FormSearchFile
Do I have to link some library files to the linker for the code to run??
How do I know which .lib files??
Som
|
|
|
|
|
Still lost, C++/CLI is C++ with .NET, you want the visual C++ forum.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
No, finally got the right one..
I am coding on C++/CLI only..
And I got the answer to my question at MSDN forums..
Thanks for the guidance..
Som
|
|
|
|
|
Notify^ notify
BufferNotifyPosition^ buffer1 = gcnew BufferNotifyPosition();
BufferNotifyPosition^ buffer2 = gcnew BufferNotifyPosition();
(the two buffer1 and buffer2 then be assigned a value but here no state)
in c#
notify.SetNotificationPosition( new BufferNotifyPosition[] { buffer1, buffer2});
in c++/cli the array type need to be cli::array<type, dimension>^
notify->SetNotificationPosition( gcnew array<BufferNotifyPosition^, 1> { buffer1, buffer2});
Here is the question:
the code in c++/cli appear an error:
error: Microsoft:DirectX:DirectSound::Notify::SetNotificationPosition: cannot convert the parameter 1 from cli::array<type, dimension>^ to cli::array<type, dimension>^
What is the problem? BufferNotifyPosition is a value class, can i create a handle BufferNotifyPostion^ buffer1?
|
|
|
|
|
Since BufferNotifyPosition is a value class, I would expect SetNotificationPosition()
to want an array of BufferNotifyPosition objects, not an array of handles to
BufferNotifyPosition objects.
Are you sure it shouldn't be something like this instead?
BufferNotifyPosition buffer1;
BufferNotifyPosition buffer2;
...
notify->SetNotificationPosition( gcnew array<BufferNotifyPosition> { buffer1, buffer2 } );
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
how Can I render dimmed a menu item programmatically
|
|
|
|
|
|
In Visual c++ NET 2005, I don,t know how to have an handle to the menu.
This function is written where
|
|
|
|
|
mikobi wrote: In Visual c++ NET 2005, I don,t know how to have an handle to the menu.
Then you need to by a beginners book on programming and probably another one on .NET programming with C++/CLI.
led mike
|
|
|
|
|
I have bought a book Visual c++ NET 2003. All things are not there.
There is no book that treat all matter.
Now I say you, I make a programme in Visual c++ Net 2005,but I need to improve it .
Don't discourage me Sir.
I learn like that Viual c++ MFC, I wrote 4 Programs that are running up to now in many businesses.
And now I am converting those programs in Visual c++ NET. I have no the same things than in MFC. And I have only one book up to now
|
|
|
|
|
mikobi wrote: There is no book that treat all matter.
Correct, that's why I said you need a C++ beginners book. Not a book specific to Visual C++ for .NET. Most of those books are going to expect a basic knowledge of C++.
My first University course was titled Programming logic and design. There was no compiler and no language, it was about learning how computer systems work and how the hardware provides a logical foundation for software development. Without a similar foundation trying to learn C/C++ is going to be far more difficult. My point is that starting at the beginning is the far better choice.
Good luck
led mike
|
|
|
|
|
Questions I ask are not logic questions but Syntax because specific to this language. What I ask, I have done it In Visual C++ MFC. But Now it is a new language that I learn.
Mister, What is the forum important if we cannot asked what we don't know.
|
|
|
|
|
In Visual c++ NET 2005, I don,t know how to have an handle to the specified menu because there is no Identification like IDC_File and so on .
This function is written where
|
|
|
|
|
Hi,
I am currently converting my VC++ project to mixed mode by enabling /clr.
But i am getting a 'System.IO.FileLoadException' in DeBug and not in Release mode, with the following information:
An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module.
Additional information: Could not load file or assembly 'MyProj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Could not find or load a type. (Exception from HRESULT: 0x80131522)
Please could someone help me to resolve this....
Regards
RMR
|
|
|
|
|
Rinnu Mary wrote: in DeBug and not in Release mode,
Difficult to do anything but guess based on the information you provided. Project settings are likely missing something for the Debug version of the settings. Maybe the reference to this 'MyProj' assembly?
led mike
|
|
|
|
|
Hi Rinnu,
Rinnu Mary wrote: An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module.
Copy the file you are trying to open into either PWD or the \Debug folder (I can never remember which...).
Rinnu Mary wrote: Additional information: Could not load file or assembly 'MyProj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Could not find or load a type. (Exception from HRESULT: 0x80131522)
I believe you are getting this because you are not catching the exception.
Jeff
|
|
|
|
|
Hi Rinnu,
I was not paying close enough attention to details... I thought I read FileNotFound exception.
Jeff
|
|
|
|
|
We ran into something that might have a bearing on this. The problem ran into was that we were getting a new library from a third party.
The developer installed it on his workstation, tested it, fixed a couple of bugs in our code and then check the project back in.
The problem is that we did not accept the library for production and he had unreference the third party library and rereferenced the new library before the check in, our build system still had the older library so it was producing broken builds.
|
|
|
|
|
Hi All,
The code below throws an exception in the finally block ('Cannot access a closed stream'). According to CryptoStream Class[^], I must call Close() on the CryptoStream. I've tried closing the inner stream first, and the inner stream last. What is the proper order/method for closing the streams?
Jeff
* Also note that if I only close the CryptoStream, no exception is thrown.
TripleDESCryptoServiceProvider^ tdes =
gcnew TripleDESCryptoServiceProvider();
...
StreamWriter^ writer;
CryptoStream^ crypto;
MemoryStream^ memory;
try
{
writer = gcnew StreamWriter(
crypto = gcnew CryptoStream(
memory = gcnew MemoryStream(),
tdes->CreateEncryptor( key, iv ),
CryptoStreamMode::Write
)
);
writer->Write( ... );
}
catch( System::Exception^ e )
{
Console::WriteLine(L"CLR Exception: {0}", e->Message);
}
finally
{
memory->Close( );
crypto->Close( );
writer->Close( );
}
|
|
|
|