简体   繁体   中英

Error with Entity Framework after installing Windows Service with WIX

i created a Windows Servicec project with Visual Studio 2012, including Entity Framework 6 to connect to my database. I added a new WIX project to create an installation package.

If i run the project in debug mode (in local from Visual Studio), it works fine. But after installation, the service returns the followning error:

No connection string named 'MyEntities' could be found in the application config file.

i'm new with Windows Installation XML (WIX), and i have no idea how to resolve the issue. i think that there is something wrong in the Product.wxs, or somewere in the WIX project...

here is the Product.wxs:

    <?xml version="1.0" encoding="UTF-8"?>
<!-- The name of the product -->
<?define Name = "MyService" ?>
<!-- The manufacturer, for setup package publisher and folder info -->
<?define Manufacturer = "MyCompanyName" ?>
<!-- The version number of this setup package-->
<?define Version = "1.0.1" ?>
<!-- UpgradeCode must be unique and not changed once the first version of the program is installed. -->
<?define UpgradeCode = "{1240E0CD-B3D2-44A7-B064-11B3C0709D69}" ?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="$(var.Name)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)" Version="$(var.Version)" Language="1033">
    <!-- Create a folder inside Talk Sharp called Test Service -->
    <Package InstallerVersion="300" Compressed="yes"/>
    <!-- Create a folder inside Talk Sharp called Test Service -->
    <Media Id="1" Cabinet="ParodosService.cab" EmbedCab="yes" />
    <!-- Allow upgrades and prevent downgrades -->
    <MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
    <!-- Define the directory structure -->
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <!-- Create a folder inside program files called Talk Sharp -->
        <Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
          <!-- Create a folder inside Talk Sharp called Test Service -->
          <Directory Id="INSTALLFOLDER" Name="$(var.Name)" />
        </Directory>
      </Directory>
    </Directory>
    <!-- The files inside this DirectoryRef are linked to the Test Service directory via INSTALLFOLDER -->
    <DirectoryRef Id="INSTALLFOLDER">
      <!-- Create a single component which is the MyService.exe file -->
      <Component Id="$(var.MyService.TargetFileName)">
        <!-- Copies the ParodosService.exe file using the project reference preprocessor variables -->
        <File Id="$(var.MyService.TargetFileName)" Source="$(var.MyService.TargetPath)" KeyPath="yes" />
        <!-- Remove all files from the INSTALLFOLDER on uninstall -->
        <RemoveFile Id="ALLFILES" Name="*.*" On="both" />
        <!-- Tell WiX to install the Service -->
        <ServiceInstall Id="ServiceInstaller" 
                        Type="ownProcess" 
                        Name="MyService" 
                        DisplayName="$(var.Name)" 
                        Description="A Test Service that logs dummy text on an interval to a text file." 
                        Start="auto" 
                        ErrorControl="normal" />
        <!-- Tell WiX to start the Service -->
        <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="MyService" Wait="yes" />
      </Component>
    </DirectoryRef>
    <!-- Tell WiX to install the files -->
    <Feature Id="MainApplication" Title="Main Application" Level="1">
      <ComponentRef Id="$(var.MyService.TargetFileName)" />
    </Feature>
  </Product>
</Wix>

Any help would be appreciated... thanks in advance.

No connection string named 'MyEntities' could be found in the application config file.

this means that no connections string named "MyEntity" was found. So, i assume that a .confg file is missing. Usually, the config file used by services to get this kind of informations is named "YourAppName.exe.config". copy this file from your project folder to your installation folder /Program Files/Manufacturer/Name Folder. you will resolve.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM