引用的SQLite.Net的程序集:
System.Data.SQLite.dll System.Data.SQLite.Linq.dll
本地VS编译成功,服务器batchbuil错误,batch代码在下面。
错误信息:
SGEN : error : Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration
batch code:
ECHO OFF
SET config=%1
IF "%config%" == "" (
set config=release
)
ECHO.Lauch build %config% ...
SET framework=Framework64
IF %PROCESSOR_ARCHITECTURE% == x86 SET framework=Framework
%WINDIR%\Microsoft.NET\%framework%\v4.0.30319\msbuild BuildWebSite.xml
pause
配置文件:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<OutDir>bin\</OutDir>
<Configuration>release</Configuration>
</PropertyGroup>
<Target Name="Build">
<ItemGroup>
<BuildProject Include="*.web/*.csproj"/>
</ItemGroup>
<MSBuild Projects="@(BuildProject)"
Properties="Configuration=$(Configuration);DebugSymbols=false;DebugType=none;
AllowedReferenceRelatedFileExtensions=false">
<Output TaskParameter="TargetOutputs" ItemName="MsBuildResult"/>
</MSBuild>
<ItemGroup>
<FileCopies Include="**\bin\$(Configuration)\*.dll"/>
</ItemGroup>
<PropertyGroup>
<RelativeOutDir>@(BuildProject->'%(RelativeDir)$(OutDir)')</RelativeOutDir>
<FullOutDir>@(BuildProject->'%(RootDir)%(Directory)$(OutDir)')</FullOutDir>
</PropertyGroup>
<Copy
SourceFiles="@(FileCopies)"
DestinationFolder="$(RelativeOutDir)"
SkipUnchangedFiles="true"
OverwriteReadOnlyFiles="true"
Retries="2"
RetryDelayMilliseconds="10"
UseHardlinksIfPossible="false"
Condition="!Exists('$(FullOutDir)%(Filename)%(Extension)')"
>
<Output TaskParameter="DestinationFiles" ItemName="CopyResult"/>
</Copy>
<Message Text="Show Result: @(CopyResult)"/>
</Target>
</Project>
可能原因:
System.Data.SQLite.dll里面混杂了x86和x64的sqlite c代码,但是我替换了两个程序集还是这个错误。
在类库中间接引用规避web引用的错误后在本地出现如下错误
试试这里的方法,在web.config中加上如下的配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
还是一样的错误~!
我想在xxx.dll.config和xxx.exe.config和app.config都应该有效,但是没有搜到web.config中成功的人。刚刚用类库间接引用规避了这个错误,但是希望知道在web中怎么配置。
@今朝-TODAY:stackoverflow上遇到的同样的问题:What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project?
Mixed mode assembly指的是C++/CLI assembly。
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>