Re: Serious bug in .NET framework 2.0 - IShellLink interface crashes
- From: "Robert Simpson" <rmsimpson@xxxxxxxxxxxxxxx>
- Date: Mon, 27 Mar 2006 12:38:59 -0700
I didn't see any reply that had a solution.
I was unable to reproduce your problem. I wrote a managed C++ console app
to test it, and created a shortcut to notepad.exe. The code compiled and
ran with 0 errors:
// linktest.cpp : main project file.
#include "stdafx.h"
#include <shlobj.h>
#include <atlbase.h>
using namespace System;
using namespace System::Runtime::InteropServices;
int main(array<System::String ^> ^args)
{
CComPtr<IShellLink> pLink;
CComQIPtr<IPersistFile> pPersist;
HRESULT hr;
hr = pLink.CoCreateInstance(CLSID_ShellLink);
if (FAILED(hr)) return 1;
pPersist = pLink;
if (!pPersist) return 2;
hr = pPersist->Load(OLESTR("c:\\Notepad.lnk"), 0);
if (FAILED(hr)) return 3;
WIN32_FIND_DATA wfd;
WCHAR szPath[MAX_PATH];
hr = pLink->GetPath(szPath, MAX_PATH, &wfd, 0);
if (FAILED(hr)) return 4;
Console::WriteLine(Marshal::PtrToStringUni((IntPtr)szPath));
return 0;
}
"Elmue" <abuse@xxxxxx> wrote in message
news:OyPPmGdUGHA.5900@xxxxxxxxxxxxxxxxxxxxxxx
Hello
Why are you calling CoInitialize(0)? Please tell me you aren't calling
it
from the DLL ...
What should be the problem with CoInitialize ?
As I wrote I call it in the constructor of the managed C++ DLL.
But this is not the cause of the problem.
Because I also tried a completely different code which I found in the
internet which does not use
any C++ code. It used COM import and directly loaded IShellLink from C#
code.
And this code had the same problem although it worked WITHOUT
CoInitialize.
But I already found a solution.
See my other posting !
Elmü
.
- References:
- Re: Serious bug in .NET framework 2.0 - IShellLink interface crashes
- From: Robert Simpson
- Re: Serious bug in .NET framework 2.0 - IShellLink interface crashes
- From: Elmue
- Re: Serious bug in .NET framework 2.0 - IShellLink interface crashes
- Prev by Date: Re: Serious bug in .NET framework 2.0 - Finally the solution
- Next by Date: Re: Serious bug in .NET framework 2.0 - Finally the solution
- Previous by thread: Re: Serious bug in .NET framework 2.0 - IShellLink interface crashes
- Next by thread: ANOTHER BIZTALK CONTRACT/ MA
- Index(es):
Relevant Pages
|