This is a multi-part message in MIME format.
--------------080507040709070501060408
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
*Hello*
I wrote an application which runs perfect under .NET framework 1.1.
I was very disappointed, that a LOT of things do NOT work on *Framework
2.0*.
This framework is NOT downward compatible.
For one of the problems I could not yet find a solution or not even an
explanation:
My project loads a managed C++ DLL which uses the *IShellLink* interface
to resolve shortcuts.
The function ResolveShortCut() (see below) is called from the main C#
program in a thread loop to
resolve all links found on the desktop.
This works perfect on .NET framework 1.1
But on Framework 2.0 the behaviour is really strange and always different:
1.)
Sometimes the function ResolveShortCut() (see below) works 10 or even
100 times without problems.
2.)
Then suddenly it happens that *CoInitialize(0)* fails.
3.)
Another time *CoCreateInstance(CLSID_ShellLink, ...)* fails.
4.)
The next time at the point *i_ShLink->GetPath(...)* a crash appears
which cannot even be caught by a
try catch block (neither in managed C++ nor in the calling C# code !!)
_*Types of Crashes*_:
1.)
Sometimes the whole application crashes without any error message.
(the application silently disappears from the screen)
2.)
Another time I get a window which asks me to send the crash information
to Microsoft
3.)
Another time I get an error telling me something about "out of memory".
(which is nonsense)
___________________________________________________________________
_*Environment:*_
The problem appears on Windows 2000 and 2003.
I use Visual Studio 2003.
The *STRANGEST* thing is that this problem appears in the following cases:
1.)
The ONLY ever installed framework = 1.1 --> everything OK
2.)
framework 1.1 + 2.0 installed --> crashes *although* my application
loads the assemblies (mscoree.dll etc..) of framework 1.1 !!
3.)
framework 2.0 *UNINSTALLED* and only framework 1.1 installed --> crashes.
It is impossible to completely UNINSTALL framework 2.0 !
I saved the registry HKLM into a *.REG file, installed framework 2.0
then uninstalled it
and compared the registry with the saved file:
The result is shocking: *hundreds of entries in the Registry* and a
dozen of files are NOT removed !!
_*Conclusion:
*_If you ever installed framework 2.0 the computer is ruined.
It is impossible to completely remove framework 2.0.
My application still crashes even after framework 2.0 was uninstalled !!!!!
I have to install a fresh Windows to get it running again !!!!
I tried this on two different computers running Windows 2000 and 2003.
I can 100% reproduce this !
Additionally another function, which *CREATES *shortcuts also crashes
sometimes.
I did not yet test, which other functions using COM are also affected.
Is this a known problem ?
What can I do ?
Thanks in advance for any answer.
*Elmü*
____________________________________________________________________
Here is the code from my managed C++ DLL.
Please don't tell me that there is any bug in this code !
It runs PERFECTLY on framework 1.1 since years.
// this line may fail
hr = CoInitialize(0) called in the contructor.
hr = CoUninitialize(0) called in the destructor.
bool Utils::ResolveShortCut(String *ps_LNKfile, // IN: the link file
to resolve
String **pps_Path, // OUT: the target file
String **pps_CmdLine) // OUT: the command
line params (if any)
{
bool b_Ret = false;
IShellLink* i_ShLink;
IPersistFile* i_Persist;
WIN32_FIND_DATA k_Find;
WORD *u16_LNKfile =
(WORD*)Marshal::StringToHGlobalUni(ps_LNKfile).ToPointer();
// this line may fail
HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (void**)&i_ShLink);
if (SUCCEEDED(hr))
{
hr = i_ShLink->QueryInterface(IID_IPersistFile, (void**)&i_Persist);
if (SUCCEEDED(hr))
{
hr = i_Persist->Load(u16_LNKfile, STGM_READ);
if (SUCCEEDED(hr))
{
hr = i_ShLink->Resolve(0, SLR_NO_UI | SLR_NOSEARCH | SLR_NOTRACK |
SLR_NOUPDATE | SLR_NOLINKINFO);
if (SUCCEEDED(hr))
{
char s8_Buf[MAX_PATH];
s8_Buf[0] = 0;
// this line may completely crash the whole application! (but
only sometimes)
hr = i_ShLink->GetPath(s8_Buf, MAX_PATH, &k_Find, SLGP_SHORTPATH);
if (SUCCEEDED(hr))
{
b_Ret = true;
*pps_Path = new String(s8_Buf);
}
s8_Buf[0] = 0;
hr = i_ShLink->GetArguments(s8_Buf, MAX_PATH);
if (SUCCEEDED(hr))
{
*pps_CmdLine = new String(s8_Buf);
}
}
}
i_Persist->Release();
}
i_ShLink->Release();
}
Marshal::FreeHGlobal(u16_LNKfile);
return b_Ret;
}
--------------080507040709070501060408
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<b>Hello</b><br>
<br>
I wrote an application which runs perfect under .NET framework 1.1.<br>
<br>
I was very disappointed, that a LOT of things do NOT work on <font
color="#990000"><b>Framework 2.0</b></font>.<br>
This framework is NOT downward compatible.<br>
<br>
For one of the problems I could not yet find a solution or not even an
explanation:<br>
<br>
My project loads a managed C++ DLL which uses the <font color="#990000"><b>IShellLink</b></font>
interface to resolve shortcuts.<br>
The function ResolveShortCut() (see below) is called from the main C#
program in a thread loop to<br>
resolve all links found on the desktop.<br>
<br>
This works perfect on .NET framework 1.1<br>
<br>
But on Framework 2.0 the behaviour is really strange and always
different:<br>
<br>
1.)<br>
Sometimes the function ResolveShortCut() (see below) works 10 or even
100 times without problems.<br>
2.)<br>
Then suddenly it happens that <b>CoInitialize(0)</b> fails.<br>
3.)<br>
Another time <b>CoCreateInstance(CLSID_ShellLink, ...)</b> fails.<br>
4.)<br>
The next time at the point <b>i_ShLink->GetPath(...)</b> a crash
appears which cannot even be caught by a<br>
try catch block (neither in managed C++ nor in the calling C# code !!)<br>
<br>
<u><b>Types of Crashes</b></u>:<br>
1.)<br>
Sometimes the whole application crashes without any error message.<br>
(the application silently disappears from the screen)<br>
2.)<br>
Another time I get a window which asks me to send the crash information
to Microsoft<br>
3.)<br>
Another time I get an error telling me something about "out of memory".
(which is nonsense)<br>
<br>
___________________________________________________________________<br>
<br>
<big><u><b>Environment:</b></u></big><br>
<br>
The problem appears on Windows 2000 and 2003.<br>
I use Visual Studio 2003.<br>
<br>
The <b>STRANGEST</b> thing is that this problem appears in the
following cases:<br>
<br>
1.)<br>
The ONLY ever installed framework = 1.1 --> everything OK<br>
2.)<br>
framework 1.1 + 2.0 installed --> crashes <b>although</b> my
application<br>
loads the assemblies (mscoree.dll etc..) of framework 1.1 !!<br>
3.)<br>
framework 2.0 <b>UNINSTALLED</b> and only framework 1.1 installed
--> crashes.<br>
<br>
<br>
It is impossible to completely UNINSTALL framework 2.0 !<br>
I saved the registry HKLM into a *.REG file, installed framework 2.0
then uninstalled it<br>
and compared the registry with the saved file:<br>
The result is shocking: <b>hundreds of entries in the Registry</b> and
a dozen of files are NOT removed !!<br>
<br>
<br>
<u><b>Conclusion:<br>
<br>
</b></u>If you ever installed framework 2.0 the computer is ruined.<br>
It is impossible to completely remove framework 2.0.<br>
My application still crashes even after framework 2.0 was uninstalled
!!!!!<br>
I have to install a fresh Windows to get it running again !!!!<br>
<br>
I tried this on two different computers running Windows 2000 and 2003.<br>
I can 100% reproduce this !<br>
<br>
Additionally another function, which <b>CREATES </b>shortcuts also
crashes sometimes.<br>
I did not yet test, which other functions using COM are also affected.<br>
<br>
Is this a known problem ?<br>
What can I do ?<br>
<br>
Thanks in advance for any answer.<br>
<br>
<b>Elmü</b><br>
<br>
____________________________________________________________________<br>
<br>
Here is the code from my managed C++ DLL.<br>
<br>
Please don't tell me that there is any bug in this code !<br>
It runs PERFECTLY on framework 1.1 since years.<br>
<br>
<br>
<font color="#000066"><tt><font color="#ff0000">// this line may fail</font><br>
hr = CoInitialize(0) called in the contructor.<br>
<br>
hr = CoUninitialize(0) called in the destructor.<br>
</tt><br>
<br>
<tt>bool Utils::ResolveShortCut(String *ps_LNKfile, // IN: the link
file to resolve<br>
String **pps_Path, // OUT: the target
file<br>
String **pps_CmdLine) // OUT: the command
line params (if any)<br>
{<br>
bool b_Ret = false;<br>
IShellLink* i_ShLink;<br>
IPersistFile* i_Persist;<br>
WIN32_FIND_DATA k_Find;<br>
<br>
WORD *u16_LNKfile =
(WORD*)Marshal::StringToHGlobalUni(ps_LNKfile).ToPointer();<br>
<br>
<font color="#ff0000"> // this line may fail</font><br>
HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER,<br>
IID_IShellLink, (void**)&i_ShLink);<br>
if (SUCCEEDED(hr))<br>
{<br>
hr = i_ShLink->QueryInterface(IID_IPersistFile,
(void**)&i_Persist);<br>
if (SUCCEEDED(hr))<br>
{<br>
hr = i_Persist->Load(u16_LNKfile, STGM_READ);<br>
if (SUCCEEDED(hr))<br>
{<br>
hr = i_ShLink->Resolve(0, SLR_NO_UI | SLR_NOSEARCH |
SLR_NOTRACK |<br>
SLR_NOUPDATE | SLR_NOLINKINFO);<br>
if (SUCCEEDED(hr))<br>
{<br>
char s8_Buf[MAX_PATH];<br>
s8_Buf[0] = 0;<br>
<br>
<font color="#ff0000"> // this line may completely crash the
whole application! (but only sometimes)</font><br>
hr = i_ShLink->GetPath(s8_Buf, MAX_PATH, &k_Find,
SLGP_SHORTPATH);<br>
if (SUCCEEDED(hr))<br>
{<br>
b_Ret = true;<br>
*pps_Path = new String(s8_Buf);<br>
}<br>
<br>
s8_Buf[0] = 0;<br>
hr = i_ShLink->GetArguments(s8_Buf, MAX_PATH);<br>
if (SUCCEEDED(hr))<br>
{<br>
*pps_CmdLine = new String(s8_Buf);<br>
}<br>
}<br>
}<br>
i_Persist->Release();<br>
}<br>
i_ShLink->Release();<br>
}<br>
Marshal::FreeHGlobal(u16_LNKfile);<br>
return b_Ret;<br>
}<br>
<br>
</tt></font><br>
</body>
</html>
--------------080507040709070501060408--