C# 错误1001 system.badimageformatexception无法在创建安装项目visual studio 2013时加载文件或程序集

C# 错误1001 system.badimageformatexception无法在创建安装项目visual studio 2013时加载文件或程序集,c#,.net,C#,.net,我在Visual Studio 2013中有一个项目,使用wpf和实体框架连接到SQL Server Express R2数据库,该项目已完成,我需要为其创建设置,我正在使用因此我创建脚本(带有数据)作为数据库的嵌入式资源,安装程序类(名为SetupInstaller)然后将项目的输出添加到安装程序中,所有内容都会生成,没有错误,但是当我尝试安装项目时,我收到了错误 错误1001 System.BadImageFormatException无法加载文件或程序集 我做了一些更改,这只是在我创建自定

我在Visual Studio 2013中有一个项目,使用wpf和实体框架连接到SQL Server Express R2数据库,该项目已完成,我需要为其创建设置,我正在使用
因此我创建脚本(带有数据)作为数据库的嵌入式资源,安装程序类(名为SetupInstaller)然后将项目的输出添加到安装程序中,所有内容都会生成,没有错误,但是当我尝试安装项目时,我收到了错误

错误1001 System.BadImageFormatException无法加载文件或程序集

我做了一些更改,这只是在我创建自定义操作时发生的,但是当我不使用它时,数据库不会被创建

我的连接线断了

<connectionStrings>    
   <add name="Bulldog_Gym.Properties.Settings.BulldogGymConnectionString" 
     connectionString="Data Source=.;Initial Catalog=BulldogGym;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
还有我的txt和数据库

我已经将数据库更改为非数据脚本,将主机添加到连接字符串,将目标从x64(当前)更改为任何CPU,但所有这些似乎都不起作用,请给我一些指导。
谢谢

这听起来好像与比特度不匹配有关。我在这里回答了一个类似的问题:


安装程序类的程序集为64位,但试图运行它的installutil.exe必须为32位,这会导致问题。不知何故,您需要执行64位版本的installutil.exe。

我将所有项目和正在使用的库都更改为x86,但仍然得到相同的错误,我仔细检查了项目,所有内容都设置为x86,我正在使用来自Forge和Secugen Fingerprint的外部库。尚未找到解决方案:(
[RunInstaller(true)]
public partial class SetupInstaller : System.Configuration.Install.Installer
{
    SqlConnection masterConnection = new SqlConnection();
    public SetupInstaller()
        : base()
    {
        InitializeComponent();
    }
    private string GetSql(string Name)
    {

        try
        {
            // Gets the current assembly.
            Assembly Asm = Assembly.GetExecutingAssembly();

            // Resources are named using a fully qualified name.
            Stream strm = Asm.GetManifestResourceStream(Asm.GetName().Name + "." + Name);

            // Reads the contents of the embedded file.
            StreamReader reader = new StreamReader(strm);
            return reader.ReadToEnd();

        }
        catch (Exception ex)
        {
            MessageBox.Show("In GetSQL: " + ex.Message);
            throw ex;
        }
    }

    private void ExecuteSql(string DatabaseName, string Sql)
    {
        System.Data.SqlClient.SqlCommand Command = new System.Data.SqlClient.SqlCommand(Sql, masterConnection);

        // Initialize the connection, open it, and set it to the "master" database
        masterConnection.ConnectionString = Properties.Settings.Default.BulldogGymConnectionString;
        Command.Connection.Open();
        Command.Connection.ChangeDatabase(DatabaseName);
        try
        {
            Command.ExecuteNonQuery();
        }
        finally
        {
            // Closing the connection should be done in a Finally block
            Command.Connection.Close();
        }
    }

    protected void AddDBTable(string strDBName)
    {
        try
        {
            // Creates the database.
            ExecuteSql("master", "CREATE DATABASE " + strDBName);

            // Creates the tables.
            ExecuteSql(strDBName, GetSql("bulldog.txt"));

            // Creates the stored procedure.
            //ExecuteSql(strDBName, GetSql("getproduct.txt"));

        }
        catch (Exception ex)
        {
            // Reports any errors and abort.
            MessageBox.Show("In exception handler: " + ex.Message);
            throw ex;
        }
    }


    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);
        AddDBTable("BulldogGym");
    }

    [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
    public override void Uninstall(IDictionary savedState)
    {
        base.Uninstall(savedState);
        ExecuteSql("master", "DROP DATABASE BulldogGym");
    }
}