I can't build project in release mode - c#-4.0

I can build project in debug mode, when I change to Release mode show this message:
The assembly mix mode was compiled in relation of version 'v2.0.50727' in runtime and do not be loaded in runtime 4.0 without configuration of additional information
File: SGEN
I don't have this file and I don't know what I can do.

http://support.microsoft.com/kb/2572158
Add the infomation below to the sgen.exe.config file located at the following location: ..\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>

Related

SGEN : error : Mixed mode assembly

Can anyone help me im getting this error when im publishing my project on release mode
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 information.
Please help me im stuck on this issue.
There is an answer in Microsoft Support (https://support.microsoft.com/en-za/help/2572158/sgen-mixed-mode-assembly-is-built-against-version-v2-0-50727-of-the-ru) which says:
In order to use mixed mode assemblies in 4.0, it must be configured in the configuration file for Sgen
Resolution
Add the information below to the sgen.exe.config file located at the following location: ..\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\
<?xml version ="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
</configuration>
For Visual Studio 2017 the path is different and can be like: c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\
For Build/Publish in Release Mode please follow below step
create a new file as sgen.exe.config
keep below code in that file
<?xml version ="1.0"?>
<configuration>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
Please keep this file in below path
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools Folder
And for x64
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64 Folder
Now restart Visual Studio
Open Project in Administrator mode and Build/Publish in Release Mode.

Can't use SharpSvn on IIS Express

When I try and create an instance of SharpSvn.SvnClient on my local development system, I'm getting System.InvalidProgramException (SharpSvn.SvnClient..ctor() in g:\dist\src\sharpsvn\svnclient.cpp:36). I'm using 32bit IIS Express 8.0 with Clr4IntegratedAppPool, 32bit version of SharpSvn, .Net 4.5, the build targets x86. I have the startup element in my Web.config file:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
After I publish my Web to IIS on a different system, it works just fine.
What am I doing wrong?
This startup flag is required whem creatimg the proces. This web.config file is parsed a bit later.
But I have news for you: Later this week there will be new SharpSvn builds available, with binaries for both .NET 2.0 and .NET 4.0. The 4.0 build won't need this flag.
[2014-04-16: The new binaries are finally pushed to our site and to NuGet]

Error doing web.config transformation for different environments

I was trying to deploy my app into different environments then i started following this how to:
Deploying an ASP.NET Web Application to a Hosting Provider using Visual Studio or Visual Web Developer: Web.Config File Transformations - 3 of 12
was perfect until I clicked in Preview Transform, I received this error:
Microsoft Visual Studio
Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
(I created just one transformation Web.DebugQA.config and of course the default ones, debug and release)
my Web.DebugQA.config looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<system.web>
</system.web>
<appSettings>
<add key="EnvironmentName" value="QADev" xdt:Transform="SetAttributes(value)"
xdt:Locator="Match(key)" />
</appSettings>
</configuration>
but then I install this plugin:
SlowCheetah - XML Transforms
and I solved my preview transform error, but then when I was trying to publish using the QADev transform I got this error:
The "ImportParametersFile" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Web.Publishing.Tasks.ImportParametersFile.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
I'm using Visual Studio Pro 2012.
I fixed this by repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012" from Control Panel --> Programs and Features.
The file Microsoft.Web.XmlTransform.dll was missing from the path C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web.
I had a similar error, although it was caused for different reasons.
I solved it copying the following DLL from another PC with VS2012 installed:
Microsoft.Web.XmlTransforms.dll
from: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
I hope this helps
I had same problem in VS2012, could not 'Preview Transform' for the PublishPackage tranforms e.g. Web.Staging.config complaining about Microsoft.Web.XmlTransform
I got it working by adding the Package https://nuget.org/packages/Microsoft.Web.Xdt to my Mvc 4.5 project. This package is still in pre release.
PM> Install-Package Microsoft.Web.Xdt -Pre
This package contains the Microsoft.Web.XmlTransform.dll
I still get an error during building complaining about "Could not load file or assembly Microsoft.Web.XmlTransform". The Mvc project has still built ok.
I did try adding the Microsoft.Web.XmlTransform.dll to the Gac using the gacutil but that did not fix the problem.
However I use Team Foundation Service build server and it works and creates the correct Web.config after applying the Web.Release.config and then the Web.Staging.config.
I tried below two things but it did not work for me.
1) copying the Microsoft.Web.XmlTransforms.dll DLL to location C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
2) And repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012"
Then I uninstalled Microsoft Azure tool V2.6 from control panel -> Programs and Features. And then I can able to publish my site.
This may have been fixed in Visual Studio 2012 Update 2 (and Visual Studio 2013).
Web.config "Preview Transform" gives an error
...
Posted by Microsoft on 3/1/2013 at 2:46 PM
Thanks for reporting the issue! It will be fixed in Visual Studio 2012 Update 2. Please install it when it becomes available.

Visual Studio 2010 hangs on "Configure Remote Desktop Connections" for Windows Azure

When trying to access the settings for the remote desktop connections in my Azure project Visual Studio 2010 SP1 hangs until forced to close. I installed the new Azure SDK (november 2011) and the problem persists. The problem occurs either by checking the box or clicking "Settings.." in the Publish window (I tried to post a screenshot but unfortunately my reputation is too low.. ;-) )
I enabled the logging in Visual Studio and got the following entries:
<entry>
<record>326</record>
<time>2011/11/15 06:55:14.972</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Entering function CVsPackageInfo::HrInstantiatePackage</description>
<guid>{8FF02D1A-C177-4AC8-A62F-88FC6EA65F57}</guid>
</entry>
<entry>
<record>327</record>
<time>2011/11/15 06:55:14.972</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Unexpected system error mode before loading package [Visual Web Developer Project Persistance Package]</description>
<guid>{8FF02D1A-C177-4AC8-A62F-88FC6EA65F57}</guid>
</entry>
<entry>
<record>328</record>
<time>2011/11/15 06:55:14.972</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Begin package load [Visual Web Developer Project Persistance Package]</description>
<guid>{8FF02D1A-C177-4AC8-A62F-88FC6EA65F57}</guid>
</entry>
<entry>
<record>329</record>
<time>2011/11/15 06:55:14.988</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Loading UI library</description>
<guid>{8FF02D1A-C177-4AC8-A62F-88FC6EA65F57}</guid>
<path>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\*\webdirprjui.dll</path>
</entry>
<entry>
<record>330</record>
<time>2011/11/15 06:55:14.988</time>
<type>Information</type>
<source>VisualStudio</source>
<description>End package load [Visual Web Developer Project Persistance Package]</description>
<guid>{8FF02D1A-C177-4AC8-A62F-88FC6EA65F57}</guid>
</entry>
</activity>
I'll be happy to provide more information if it's helpful.
I recreated what was my problem and solved it. Steps:
1.Add a certificate.
1.1 In the web-role project, open the configuration file under Roles and then select Certificates in the left menu.
1.2 Click Add Certificate. (just leave it as it is created).
1.3 Save.
2. Try to open Remote desktop configuration.
2.1 Visual Studio hangs.
3. Solve it.
3.1 Restart Visual studio.(Always as administrator).
3.2 Remove the certificate.
3.3 Try to open Remote desktop configuration.
3.4 It should now work. Well.. It does for me.
Really need more information to troubleshoot this. Can you capture a hang dump when this happens and open the dump and let us see the callstack that is hanging?
You could also try running procmon and procexp to see if you see any errors in them:
http://technet.microsoft.com/en-us/sysinternals/bb896645
http://technet.microsoft.com/en-us/sysinternals/bb896653

Specifying a VC++ Redistributable version for ClickOnce prerequisite

My ClickOnce application uses a third party tool that requires the Visual C++ 2005 redistributable. The third party tool will not work if only the VC++ 2008 redistributable is installed. However, in Visual Studio 2008, the ClickOnce prerequisites do not allow a version to be specified for the VC++ redistributable; it will add a VC++ 2008 prerequisite, which makes sense most of the time. However, in this situation, an earlier version is required. ClickOnce is required, so merge modules are out of the question. Any ideas of how to specify the version?
If you can find a machine with VS 2005 installed, the solution shouldn't be too hard. You have the ability to customize what appears in the Prerequisites dialog on the Publish tab of your project.
On a machine with VS 2005 installed, go to \Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages and copy the vsredist_x86 folder to the machine you are publishing from.
Rename the folder, call it vsredist_x86_2005 or something similar.
Inside the folder, edit the \en\package.xml file. Change the <String Name="DisplayName"> tag to something that makes sense (Visual C++ 2005 Runtime Libraries (x86)) to differentiate it from the existing 2008 package.
Copy the folder to C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages.
Restart Visual Studio if it is open.
Now, when you open the Prerequisites dialog you should see a new entry for the 2005 package. I didn't completely test this solution so I may have missed a few details but hopefully this gets you started.
I believe you can open the manifest file for your app and modify the versions of the redists your app should be linking against. The listings in the manifest should match what you have in your C:\Windows\WinSxS dirs. There is a CodeProject page that gives a good description of using different redistributables.
I just installed Visual Studio 2005. Here is an original bootstrapper:
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86\
\en\package.xml
<?xml version="1.0" encoding="utf-8" ?>
<Package
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
Name="DisplayName"
Culture="Culture"
>
<!-- Defines a localizable string table for error messages-->
<Strings>
<String Name="DisplayName">Visual C++ Runtime Libraries (x86)</String>
<String Name="Culture">en</String>
<String Name="AdminRequired">You do not have the permissions required to install Visual C++ Runtime Libraries (x86). Please contact your administrator.</String>
<String Name="InvalidPlatformWin9x">Installation of Visual C++ Runtime Libraries (x86) is not supported on Windows 95. Contact your application vendor.</String>
<String Name="InvalidPlatformWinNT">Installation of Visual C++ Runtime Libraries (x86) is not supported on Windows NT 4.0. Contact your application vendor.</String>
<String Name="GeneralFailure">A failure occurred attempting to install Visual C++ Runtime Libraries (x86).</String>
</Strings>
</Package>
\product.xml
<?xml version="1.0" encoding="utf-8" ?>
<Product
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
ProductCode="Microsoft.Visual.C++.8.0.x86"
>
<!-- Defines list of files to be copied on build -->
<PackageFiles>
<PackageFile Name="vcredist_x86.exe"/>
</PackageFiles>
<InstallChecks>
<MsiProductCheck Property="VCRedistInstalled" Product="{A49F249F-0C91-497F-86DF-B2585E8E76B7}"/>
</InstallChecks>
<!-- Defines how to invoke the setup for the Visual C++ 8.0 redist -->
<!-- TODO: Needs EstrimatedTempSpace, LogFile, and an update of EstimatedDiskSpace -->
<Commands Reboot="Defer">
<Command PackageFile="vcredist_x86.exe"
Arguments=' /q:a '
>
<!-- These checks determine whether the package is to be installed -->
<InstallConditions>
<BypassIf Property="VCRedistInstalled" Compare="ValueGreaterThanOrEqualTo" Value="3"/>
<!-- Block install if user does not have admin privileges -->
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
<!-- Block install on Win95 -->
<FailIf Property="Version9X" Compare="VersionLessThan" Value="4.10" String="InvalidPlatformWin9x"/>
<!-- Block install on NT 4 or less -->
<FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.00" String="InvalidPlatformWinNT"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
</Commands>
</Product>
\vcredist_x86.exe
SHA1: 95040f80b0d203e1abaec4e06e0ec0e01c507d03

Resources