Protecting a Windows Service assembly.

396 views
Skip to first unread message

mw

unread,
Sep 9, 2008, 6:41:24 AM9/9/08
to .Net Reactor Support
Hi,

I was trying to protect a windows service but an exception is thrown
while installing the service using installutil. The service installs
fine before the protection was applied. The exception that I was
getting was:

Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly
'file:///C:\MyService.exe' or one of its dependencies. The module was
expected to contain an assembly manifest..

Also what would happen if I lock the service.exe to expire after a
certain time? Will the service just not be able to start after that
time?

Thanks!

Tim Haughton

unread,
Sep 9, 2008, 6:46:10 AM9/9/08
to net-react...@googlegroups.com
It's a looong time since I've done a Windows service in .Net, but I seem to remember custom install actions that are built as classes within the service. Perhaps these shouldn't be obfuscated.

Regards,

Tim Haughton
www.agilemicroisv.com

2008/9/9 mw <munwa...@gmail.com>

Denis

unread,
Sep 9, 2008, 8:10:27 AM9/9/08
to .Net Reactor Support
Did you protect the windows service in "Application" mode? Windows
services should be always protected in "Library" mode.

Greetings,

Denis

On 9 Sep., 12:46, "Tim Haughton" <timhaugh...@gmail.com> wrote:
> It's a looong time since I've done a Windows service in .Net, but I seem to
> remember custom install actions that are built as classes within the
> service. Perhaps these shouldn't be obfuscated.
>
> Regards,
>
> Tim Haughtonwww.agilemicroisv.com
>
> 2008/9/9 mw <munwaic...@gmail.com>

mw

unread,
Sep 9, 2008, 10:44:24 PM9/9/08
to .Net Reactor Support
I tried that and got the following exception when trying to install
the service

An exception occurred during the Install phase.
System.InvalidOperationException: Unable to create an instance of the
MyService.ProjectInstaller installer type.
The inner exception System.Reflection.TargetInvocationException was
thrown with the following error message: Exception has been thrown by
the target of an invocation..
The inner exception System.TypeInitializationException was thrown with
the following error message: The type initializer for
'MyService.ProjectInstaller' threw an exception..
The inner exception System.DivideByZeroException was thrown with the
following error message: Attempted to divide by zero..

So, I have basically given up and think that I should just protect
each dll one by one.


Mun Wai

Mun Wai Chan

unread,
Sep 10, 2008, 2:49:42 AM9/10/08
to .Net Reactor Support
Actually, it looks like I have to tick the "mergeassemblies" for it to work and not get the exception. Not sure why....

mw

unread,
Sep 10, 2008, 3:02:46 AM9/10/08
to .Net Reactor Support
Sorry, my mistake. I have 2 services and it only worked on one. The
other is still giving the same exception.


On Sep 10, 2:49 pm, "Mun Wai Chan" <munwaic...@gmail.com> wrote:
> Actually, it looks like I have to tick the "mergeassemblies" for it to work
> and not get the exception. Not sure why....
>

Tim Haughton

unread,
Sep 10, 2008, 3:05:31 AM9/10/08
to net-react...@googlegroups.com
Can you create a simple solution that recreates the problem, and upload the solution along with your reactor project file?

Regards,

Tim Haughton
www.agilemicroisv.com

2008/9/10 mw <munwa...@gmail.com>

mw

unread,
Sep 10, 2008, 4:04:43 AM9/10/08
to .Net Reactor Support
I have managed to recreate the problem and have attached the solution
as WindowsService3. The password to the PFX file is service. I am
thinking it is a bug with NecroBit when the assembly is signed for a
Windows Service. So when trying to protect the assembly, please enable
Necrobit.

On Sep 10, 3:05 pm, "Tim Haughton" <timhaugh...@gmail.com> wrote:
> Can you create a simple solution that recreates the problem, and upload the
> solution along with your reactor project file?
>
> Regards,
>
> Tim Haughtonwww.agilemicroisv.com
>
> 2008/9/10 mw <munwaic...@gmail.com>

Tim Haughton

unread,
Sep 10, 2008, 4:07:29 AM9/10/08
to net-react...@googlegroups.com
Would you mind uploading your project file too.

Regards,

Tim Haughton
www.agilemicroisv.com

2008/9/10 mw <munwa...@gmail.com>

mw

unread,
Sep 10, 2008, 4:10:48 AM9/10/08
to .Net Reactor Support
Done!

On Sep 10, 4:07 pm, "Tim Haughton" <timhaugh...@gmail.com> wrote:
> Would you mind uploading your project file too.
>
> Regards,
>
> Tim Haughtonwww.agilemicroisv.com
>
> 2008/9/10 mw <munwaic...@gmail.com>

Tim Haughton

unread,
Sep 10, 2008, 4:12:01 AM9/10/08
to net-react...@googlegroups.com
Super. I don't have Reactor with me at the moment, I'll have a look when I get home tonight, unless Denis beats me to it :)

Regards,

Tim Haughton
www.agilemicroisv.com

2008/9/10 mw <munwa...@gmail.com>

mw

unread,
Sep 10, 2008, 4:13:34 AM9/10/08
to .Net Reactor Support
Or you can just download the demo version :P. Thanks for your effort
anyway!

On Sep 10, 4:12 pm, "Tim Haughton" <timhaugh...@gmail.com> wrote:
> Super. I don't have Reactor with me at the moment, I'll have a look when I
> get home tonight, unless Denis beats me to it :)
>
> Regards,
>
> Tim Haughtonwww.agilemicroisv.com
>
> 2008/9/10 mw <munwaic...@gmail.com>

Denis

unread,
Sep 10, 2008, 11:48:55 AM9/10/08
to .Net Reactor Support
Hi,

I have checked the files and fixed the issue. The following version
should work as expected now:
http://www.eziriz.com/downloads/dotnet_reactor_setup__latest.exe

>>Also what would happen if I lock the service.exe to expire after a certain time? Will the service just not be able to start after that time?

You need to set "Shutdown Process After Expiration" to false and check
the current license status via the SDK by yourself.

Greetings,

Denis

mw

unread,
Sep 10, 2008, 9:27:01 PM9/10/08
to .Net Reactor Support
Thanks!!

mw

unread,
Sep 11, 2008, 1:51:17 AM9/11/08
to .Net Reactor Support
FYI, I had to use Pack Assembly instead of Merge Assemblies before it
worked as it was spitting out another exception about not being able
to locate one of the dlls being referenced.
Reply all
Reply to author
Forward
0 new messages