C# 不应加载引用程序集以执行。它们只能在仅反射加载程序上下文中加载
好的,我有一个wpf应用程序,可以与postgresql数据库交互,我正在使用Npgsql,当测试一切正常时,没有异常,但是当我为我的应用程序创建setup.exe并运行它时,我尝试登录,但它给了我这个异常 下面是导致异常的块C# 不应加载引用程序集以执行。它们只能在仅反射加载程序上下文中加载,c#,wpf,postgresql,exception,runtimeexception,C#,Wpf,Postgresql,Exception,Runtimeexception,好的,我有一个wpf应用程序,可以与postgresql数据库交互,我正在使用Npgsql,当测试一切正常时,没有异常,但是当我为我的应用程序创建setup.exe并运行它时,我尝试登录,但它给了我这个异常 下面是导致异常的块 private void LoginButton_Click(object sender, RoutedEventArgs e) { username = user.Text; password = pa
private void LoginButton_Click(object sender, RoutedEventArgs e)
{
username = user.Text;
password = pass.Password;
// Specify connection
NpgsqlConnection conn = new NpgsqlConnection( // the exception occurs here
"Server=127.0.0.1;" + // I also tried to set the server url to my pc's ip address on the local network but still the same problem
"User Id=username;" +
"Password=password;" +
"Database=db;" +
"Port=3500");
conn.Open();
// Define a query
NpgsqlCommand cmd = new NpgsqlCommand($"SELECT resid FROM resaccounts WHERE username = '{username}' and password = '{password}';", conn);
// Execute a query
NpgsqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
// Specify connection
NpgsqlConnection conn2 = new NpgsqlConnection(
"Server=127.0.0.1;" +
"User Id=adminBakri;" +
"Password=snoffi9000bakri6;" +
"Database=shobek_lobek_db;" +
"Port=3500");
conn2.Open();
// Define a query
NpgsqlCommand cmd2 = new NpgsqlCommand($"SELECT name FROM restaurants WHERE id = {(int)dr[0]};", conn2);
// Execute a query
NpgsqlDataReader dr2 = cmd2.ExecuteReader();
if (dr2.Read())
{
try
{
Properties.Settings.Default.UserName = Encrypt(username);
Properties.Settings.Default.UserPassword = Encrypt(password);
Properties.Settings.Default.ResId = (int)dr[0];
Properties.Settings.Default.ResName = dr2[0].ToString();
Properties.Settings.Default.Save();
}
catch (Exception exp)
{
Console.WriteLine(exp);
}
this.Hide();
Window mainWindow = new MainWindow();
mainWindow.Show();
this.Close();
}
conn2.Close();
}
else
{
Console.WriteLine("Error, Wrong info");
}
// Close connection
conn.Close();
}
我还拥有所有nuget软件包的最新版本,包括System.ValueTuple和Npgsql
我按照本文中的步骤为我的应用程序创建了setup.exe,我不知道问题出在哪里
请帮帮我,谢谢
编辑:额外信息:我没有使用MVVM
编辑:添加有关如何制作SETUP.EXE的步骤
步骤1:我在解决方案中添加了一个安装项目
步骤2:我有以下文件夹
步骤3:我在前两个文件夹中添加了以下内容
到目前为止,我有以下几点:
在应用程序文件夹中:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F2571E19-BB3A-46FA-B1A1-15ECD9392887}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Food_Ordering_Res</RootNamespace>
<AssemblyName>Restaurants Helper</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
<LangVersion>8.0</LangVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<ApplicationIcon>main_logo2_qAL_icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Food_Ordering_Res.App</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ConfirmLogOut.xaml.cs">
<DependentUpon>ConfirmLogOut.xaml</DependentUpon>
</Compile>
<Compile Include="IncomeInfoWindow.xaml.cs">
<DependentUpon>IncomeInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Login.xaml.cs">
<DependentUpon>Login.xaml</DependentUpon>
</Compile>
<Compile Include="MealEditWindow.xaml.cs">
<DependentUpon>MealEditWindow.xaml</DependentUpon>
</Compile>
<Compile Include="NotificationService.cs" />
<Compile Include="OfflineMealAdditionInfoWindow.xaml.cs">
<DependentUpon>OfflineMealAdditionInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="RelayCommand.cs" />
<Compile Include="Splash.xaml.cs">
<DependentUpon>Splash.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlAddCategory.xaml.cs">
<DependentUpon>UserControlAddCategory.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlAddMeal.xaml.cs">
<DependentUpon>UserControlAddMeal.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlCheckBalance.xaml.cs">
<DependentUpon>UserControlCheckBalance.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlEditMeal.xaml.cs">
<DependentUpon>UserControlEditMeal.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlExpenses.xaml.cs">
<DependentUpon>UserControlExpenses.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlHome.xaml.cs">
<DependentUpon>UserControlHome.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlOfflineMealAddition.xaml.cs">
<DependentUpon>UserControlOfflineMealAddition.xaml</DependentUpon>
</Compile>
<Page Include="ConfirmLogOut.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="IncomeInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Login.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="MealEditWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="OfflineMealAdditionInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Splash.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlAddCategory.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlAddMeal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlCheckBalance.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlEditMeal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlExpenses.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlHome.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlOfflineMealAddition.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Resource Include="main_logo2_qAL_icon.ico" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Resource Include="Assets\home.png" />
<Resource Include="Assets\1.png" />
<Resource Include="Assets\2.png" />
<Resource Include="Assets\3.png" />
<Resource Include="Assets\4.png" />
<Content Include="Fonts\ae_Dimnah.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LoadingIndicators.WPF">
<Version>0.0.1</Version>
</PackageReference>
<PackageReference Include="MaterialDesignColors">
<Version>1.1.2</Version>
</PackageReference>
<PackageReference Include="MaterialDesignThemes">
<Version>2.3.1.953</Version>
</PackageReference>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Contracts">
<Version>10.0.18362.2005</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="Npgsql">
<Version>4.1.3.1</Version>
</PackageReference>
<PackageReference Include="Portable.BouncyCastle">
<Version>1.8.6.7</Version>
</PackageReference>
<PackageReference Include="RestSharp">
<Version>106.10.1</Version>
</PackageReference>
<PackageReference Include="System.Buffers">
<Version>4.5.1</Version>
</PackageReference>
<PackageReference Include="System.Memory">
<Version>4.5.4</Version>
</PackageReference>
<PackageReference Include="System.Numerics.Vectors">
<Version>4.5.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe">
<Version>4.7.1</Version>
</PackageReference>
<PackageReference Include="System.Runtime.WindowsRuntime">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.WindowsRuntime.UI.Xaml">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Text.Encodings.Web">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Text.Json">
<Version>4.7.1</Version>
</PackageReference>
<PackageReference Include="System.Threading.Tasks.Extensions">
<Version>4.5.4</Version>
</PackageReference>
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
在程序文件文件夹中:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F2571E19-BB3A-46FA-B1A1-15ECD9392887}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Food_Ordering_Res</RootNamespace>
<AssemblyName>Restaurants Helper</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
<LangVersion>8.0</LangVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<ApplicationIcon>main_logo2_qAL_icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Food_Ordering_Res.App</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ConfirmLogOut.xaml.cs">
<DependentUpon>ConfirmLogOut.xaml</DependentUpon>
</Compile>
<Compile Include="IncomeInfoWindow.xaml.cs">
<DependentUpon>IncomeInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Login.xaml.cs">
<DependentUpon>Login.xaml</DependentUpon>
</Compile>
<Compile Include="MealEditWindow.xaml.cs">
<DependentUpon>MealEditWindow.xaml</DependentUpon>
</Compile>
<Compile Include="NotificationService.cs" />
<Compile Include="OfflineMealAdditionInfoWindow.xaml.cs">
<DependentUpon>OfflineMealAdditionInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="RelayCommand.cs" />
<Compile Include="Splash.xaml.cs">
<DependentUpon>Splash.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlAddCategory.xaml.cs">
<DependentUpon>UserControlAddCategory.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlAddMeal.xaml.cs">
<DependentUpon>UserControlAddMeal.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlCheckBalance.xaml.cs">
<DependentUpon>UserControlCheckBalance.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlEditMeal.xaml.cs">
<DependentUpon>UserControlEditMeal.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlExpenses.xaml.cs">
<DependentUpon>UserControlExpenses.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlHome.xaml.cs">
<DependentUpon>UserControlHome.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlOfflineMealAddition.xaml.cs">
<DependentUpon>UserControlOfflineMealAddition.xaml</DependentUpon>
</Compile>
<Page Include="ConfirmLogOut.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="IncomeInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Login.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="MealEditWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="OfflineMealAdditionInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Splash.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlAddCategory.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlAddMeal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlCheckBalance.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlEditMeal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlExpenses.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlHome.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlOfflineMealAddition.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Resource Include="main_logo2_qAL_icon.ico" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Resource Include="Assets\home.png" />
<Resource Include="Assets\1.png" />
<Resource Include="Assets\2.png" />
<Resource Include="Assets\3.png" />
<Resource Include="Assets\4.png" />
<Content Include="Fonts\ae_Dimnah.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LoadingIndicators.WPF">
<Version>0.0.1</Version>
</PackageReference>
<PackageReference Include="MaterialDesignColors">
<Version>1.1.2</Version>
</PackageReference>
<PackageReference Include="MaterialDesignThemes">
<Version>2.3.1.953</Version>
</PackageReference>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Contracts">
<Version>10.0.18362.2005</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="Npgsql">
<Version>4.1.3.1</Version>
</PackageReference>
<PackageReference Include="Portable.BouncyCastle">
<Version>1.8.6.7</Version>
</PackageReference>
<PackageReference Include="RestSharp">
<Version>106.10.1</Version>
</PackageReference>
<PackageReference Include="System.Buffers">
<Version>4.5.1</Version>
</PackageReference>
<PackageReference Include="System.Memory">
<Version>4.5.4</Version>
</PackageReference>
<PackageReference Include="System.Numerics.Vectors">
<Version>4.5.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe">
<Version>4.7.1</Version>
</PackageReference>
<PackageReference Include="System.Runtime.WindowsRuntime">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.WindowsRuntime.UI.Xaml">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Text.Encodings.Web">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Text.Json">
<Version>4.7.1</Version>
</PackageReference>
<PackageReference Include="System.Threading.Tasks.Extensions">
<Version>4.5.4</Version>
</PackageReference>
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
步骤4:我在ProgramFiles文件夹中创建了一个文件的快捷方式,并将其添加到用户桌面和用户程序菜单的文件夹中
步骤5:我为所有文件夹将AlwaysCreate属性值设置为True
步骤6:我现在做的是重建解决方案并重建安装项目,然后我转到安装项目的调试文件夹并从setup.msi安装应用程序
这是我的.csproj文件:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F2571E19-BB3A-46FA-B1A1-15ECD9392887}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Food_Ordering_Res</RootNamespace>
<AssemblyName>Restaurants Helper</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
<LangVersion>8.0</LangVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<ApplicationIcon>main_logo2_qAL_icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Food_Ordering_Res.App</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ConfirmLogOut.xaml.cs">
<DependentUpon>ConfirmLogOut.xaml</DependentUpon>
</Compile>
<Compile Include="IncomeInfoWindow.xaml.cs">
<DependentUpon>IncomeInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Login.xaml.cs">
<DependentUpon>Login.xaml</DependentUpon>
</Compile>
<Compile Include="MealEditWindow.xaml.cs">
<DependentUpon>MealEditWindow.xaml</DependentUpon>
</Compile>
<Compile Include="NotificationService.cs" />
<Compile Include="OfflineMealAdditionInfoWindow.xaml.cs">
<DependentUpon>OfflineMealAdditionInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="RelayCommand.cs" />
<Compile Include="Splash.xaml.cs">
<DependentUpon>Splash.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlAddCategory.xaml.cs">
<DependentUpon>UserControlAddCategory.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlAddMeal.xaml.cs">
<DependentUpon>UserControlAddMeal.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlCheckBalance.xaml.cs">
<DependentUpon>UserControlCheckBalance.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlEditMeal.xaml.cs">
<DependentUpon>UserControlEditMeal.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlExpenses.xaml.cs">
<DependentUpon>UserControlExpenses.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlHome.xaml.cs">
<DependentUpon>UserControlHome.xaml</DependentUpon>
</Compile>
<Compile Include="UserControlOfflineMealAddition.xaml.cs">
<DependentUpon>UserControlOfflineMealAddition.xaml</DependentUpon>
</Compile>
<Page Include="ConfirmLogOut.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="IncomeInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Login.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="MealEditWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="OfflineMealAdditionInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Splash.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlAddCategory.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlAddMeal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlCheckBalance.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlEditMeal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlExpenses.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlHome.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControlOfflineMealAddition.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Resource Include="main_logo2_qAL_icon.ico" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Resource Include="Assets\home.png" />
<Resource Include="Assets\1.png" />
<Resource Include="Assets\2.png" />
<Resource Include="Assets\3.png" />
<Resource Include="Assets\4.png" />
<Content Include="Fonts\ae_Dimnah.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LoadingIndicators.WPF">
<Version>0.0.1</Version>
</PackageReference>
<PackageReference Include="MaterialDesignColors">
<Version>1.1.2</Version>
</PackageReference>
<PackageReference Include="MaterialDesignThemes">
<Version>2.3.1.953</Version>
</PackageReference>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Contracts">
<Version>10.0.18362.2005</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="Npgsql">
<Version>4.1.3.1</Version>
</PackageReference>
<PackageReference Include="Portable.BouncyCastle">
<Version>1.8.6.7</Version>
</PackageReference>
<PackageReference Include="RestSharp">
<Version>106.10.1</Version>
</PackageReference>
<PackageReference Include="System.Buffers">
<Version>4.5.1</Version>
</PackageReference>
<PackageReference Include="System.Memory">
<Version>4.5.4</Version>
</PackageReference>
<PackageReference Include="System.Numerics.Vectors">
<Version>4.5.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe">
<Version>4.7.1</Version>
</PackageReference>
<PackageReference Include="System.Runtime.WindowsRuntime">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.WindowsRuntime.UI.Xaml">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Text.Encodings.Web">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Text.Json">
<Version>4.7.1</Version>
</PackageReference>
<PackageReference Include="System.Threading.Tasks.Extensions">
<Version>4.5.4</Version>
</PackageReference>
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
调试
任意CPU
{F25711E19-BB3A-46FA-B1A1-15ECD9392887}
温克斯
食物订购
餐厅帮手
v4.8
10.0.10240.0
8
512
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4.
真的
任意CPU
真的
满的
假的
bin\Debug\
调试;痕迹
促使
4.
假的
任意CPU
pdbonly
真的
bin\Release\
痕迹
促使
4.
假的
主图标2_qAL_icon.ico
食品订购应用程序
4
MSBuild:编译
设计师
ConfirmLogOut.xaml
IncomeInfoWindow.xaml
Login.xaml
MealEditWindow.xaml
OfflineMealAdditionInfoWindow.xaml
Splash.xaml
UserControlAddCategory.xaml
UserControlAddDime.xaml
UserControlCheckBalance.xaml
UserControlEditDime.xaml
UserControlExpenses.xaml
UserControlHome.xaml
UserControlOfflineMealAddition.xaml
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
MSBuild:编译
设计师
App.xaml
代码
MainWindow.xaml
代码
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
代码
真的
真的
Resources.resx
真的
设置。设置
真的
ResXFileCodeGenerator
Resources.Designer.cs
总是
设置单个文件生成器
Settings.Designer.cs
0.0.1
1.1.2
2.3.1.953
1.1.0
10.0.18362.2005
12.0.3
4.1.3.1
1.8.6.7
106.10.1
4.5.1
4.5.4
4.5.0
4.7.1
4.7.0
4.7.0
4.7.0
4.7.1
4.5.4
4.5.0
您的csproj文件的目标是.NET Framework v 4.8,它已经嵌入System.ValueTuple。我怀疑烘焙版本和作为Nuget包添加的版本之间存在冲突
只需删除
系统的包引用
。ValueTuple
(删除Nuget包)并重新构建就可以了,代码中可能有一些“正在使用”的引用也需要删除。这似乎是解决问题的一个很长的方法,但取决于Dean所说的,您应该尝试创建一个新项目,并将目标framework设置为.Net framework 4.6.1,然后将所有文件从旧项目复制到新项目,然后重新尝试所有操作
希望这能解决您的问题。您需要包括有关如何添加程序集的特定详细信息,因为您的操作不正确,而这正是造成问题的原因。一步一步地看你是如何做到的,这将有助于我们指出你在这一步上犯了错误。还可以编辑您的问题,以包含您的
.csproj
file@ScottChamberlain好的,我马上就发now@ScottChamberlain我补充了你的问题不确定你的问题是什么。csproj在我看来很好。我看不到会导致您收到错误的正常情况。我尝试删除该软件包,但它仍然不起作用,谢谢您的回答