473,804 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LayoutKind.Expl icit breaks service install

I have a structure declared as:

[StructLayout(La youtKind.Explic it, Size=6)]
private struct StandardFrame
{
[FieldOffset(0)] public byte [] frame;
[FieldOffset(0)] public UInt32 integrityCheck;
[FieldOffset(2)] public UInt32 sequenceNo;
[FieldOffset(4)] public UInt32 dataLength;

}

This is part of a Windows Service C# app. I've added an installer and
setup project but the install fails with "Unable to get installer types
in the <name of executable> --> one or more of the types in the
assembly unable to load."

I've narrowed the problem down to this struct. If I make the struct
LayoutKind.Sequ ential and remove the FieldOffset values the service
installs no problem. Obviously this is not what I want, the struct is
to be used as a union. This has really got me stumped, I can work
around it but I would prefer to use this approach.

Any clues gratefully accepted.

Nov 17 '05
13 1776
I have code in VB.Net to install a service using the API. If you're
interested, I can post it.

Nov 17 '05 #11
Wow, first thanks for all the responses.

Ignacio, you are correct, I should have tested the class containing the
structure before slapping it into a service. I was reusing code from an
existing service that didn't have a separate test harness so I was
winging it and got burnt.

Chris, yes I would be curious to see the service install using the API.
Is there a particular reason you went that route? Once I fixed the
struct issue the installer worked fine.

I guess the thing that really bit me was that I was able to declare the
invalid struct but it wasn't until runtime that my error was caught
(I'm talking about not being able to use explicit offsets with
reference types rather than specifying UInt32 instead of UInt16). This
probably reflects a poor development approach on my part, plus coming
from a c++ background I did tend to rely on the compiler to highlight
this kind of mistake. I will assume that due to the way attributes are
implemented this kind of error is difficult to pick up at compile time.

So the approach I'm now taking is to ditch the struct and use
Buffer.BlockCop y() to get the values I need. I would be curious also to
know if there is a better approach to doing this transformation.
Basically I need to convert between 3 UInt16's and 6 bytes as a header
for a data packet.

Thanks and regards

Nov 17 '05 #12
Dave wrote:
Chris, yes I would be curious to see the service install using the API.
Is there a particular reason you went that route? Once I fixed the
struct issue the installer worked fine.


My reason for going that route is that I wanted the service be able to
install itself without the need for an external utility. So with my
code, I can just call progname /install to install the service or
progname /uninstall to uninstall it.

Check this link:

http://tinyurl.com/7382d

Nov 17 '05 #13
Nice, thanks for posting Chris. And yes I can see the advantage to
being able to install the traditional way.

Dave

Nov 17 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1390
by: chriss | last post by:
Hello everybody! I'm very bad in English but I'm going to try to explain my problem. I have a python program and this program is a service. chronologically: 1. I install my program like service -> it's ok 2. I start the service -> it's ok 3. I stop the service -> it's ok
4
386
by: DraguVaso | last post by:
Hi, I developped a Windows Service in VB.NET (2005). I need to have it installed two times on 1 machine. When I want to install it a second time, the setup doesn't allow me to install it again in an other directory, but only to repair or remove the other version. I get arround this by simply copying the files of the first installed in a second directory.
0
1664
by: poi | last post by:
Running the code below, I get the error Cannot start service from the command line opr debugger. A Windows Service must first be installed (using installutil.exe) and then started with the ServerExplorer..... But the text log from my install shows this: Running a transacted installation.
4
13909
by: Chua Wen Ching | last post by:
Hi there, I had a union in C: typedef union TagMessage { struct { unsigned char avalue; unsigned char bvalue; } a;
3
57011
by: Jeremy S. | last post by:
On my dev machine (XP/Pro with VS.NET 2003) I have been developing a Windows Service and installing it on the local machine by opening the Visual Studio Command Prompt and then executing . Now I want to test this service on a Windows Server 2003 box that doesn't have the Visual Studio Command prompt. How do I go about installing the service on the Windows Server 2003 box? Thanks!
2
4691
by: letibal | last post by:
Hello, I have written a windows service and created an installer for it. The service runs under the system accounts. When started, it launches a GUI. By default, the InteractiveProcess property of the service is not set (this can be checked by right-clicking on the service in the Services window (Admin tools>Services), choosing Properties, LogOn tab). In order to enable my service to launch a GUI at startup, I added the following lines...
15
4236
by: Joseph Geretz | last post by:
OK, I'll admit it up front - I just don't get it. Here's our previous VS2003 development model. Developers develop the WS solution on their own workstations, using their own IIS web servers mapped to the local devleopment folder. Project compiles to a subfolder .\bin. To deploy, the asmx page and bin subfolder are copied to the production server. So now I upgrade to VS2005. OK, so except for the name, everything is changed. No more...
0
1063
by: Ayrin | last post by:
The code below works fine on my Windows2003, dotnet 1.1 server. UNTIL I install service pak one for Windows 2003. After I install SP1 this code brings up the Open/save box but one you select something, nothing happens (0% downloads) If I run this code on my dev machine with winXPsp2 and IE7, the code only works for text files. Other files will download, but they are corrupt when I open them.(missing bytes I think) Does anyone have...
5
3313
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name? Why do I need to set a property within my code to the service name? Are all these required or am I just doing this for consistency purposes?
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9593
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7633
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.