VSTO Add-In DLL, rights to launch a Win32 executable

N

NickP

Hi there,

I have a VSTO Add-in DLL which as well as including a few other .NET
DLLs as dependency, it also includes a Win32 executable, which needs to be
launched by one of the DLLs.

In the same folder I have a test executable which launches the same code
within a form, all works perfectly. Unfortunately when launched within
Microsoft Word, the Win32 executable fails to launch, even thought it is
exactly the same code.

I am presuming that this is down to some priviledges. How would I allow
the .NET DLL to launch the executable? Many thanks in advance for your time
and help.

Nick.
 
N

NickP

Please disregard this. It turned out that the DLL was looking for the exe
in the current directory, and this it is completely different when being
launched as an addin, so I acquired the location of the add-in via a
registry that was created upon installation, then set the current directory
to that.

Nick.
 
M

Michael Reukauff

Yes, or you can use the following code snippet to get the original path of
the DLL:
string xAssemblyPath =
System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
strConfigPath = Path.GetDirectoryName(xAssemblyPath);
Uri xUri = new Uri(xAssemblyPath);

Michael
 
N

NickP

Hi Michael,

Unfortunately I tried a few variants of getting the current directory of
the executing assembly, but it returns some odd path with strong name keys
and the like. Although I'm not sure that I tried exactly what you have
suggested there.

Many thanks none the less.

Nick.
 
J

Jialiang Ge [MSFT]

Hello Nick,

System.Reflection.Assembly.GetExecutingAssembly(). Location is only able to
return the temporary path your application uses to run the assembly. Please
try the method: AppDomain.CurrentDomain.BaseDirectory. It should be able to
help you retrieve the real directory of the assembly.

If you have any other concern or need anything else, please feel free to
let me know.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Michael Reukauff

Hi Jialiang Ge

Yes that is much better. Thanks. Didn't know that one.

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top