Unity.Configuration Issue while migrating from VS 2013 to 2015 - unity-container

While migrating from VS 2013 to 2015. I started getting run time error of Unity.Configuration - The type name or alias XXXX could not be resolved. Please check your configuration file and verify this type name."}
I tried below few options in configuration file but it didn't help
<alias alias="XXXX" type="namespace.XXXX, assembly_name" />
<namespace name="namespace" />
<assembly name="assembly_name" />
<typeAlias alias="XXXX" type="namespace.XXXX, assembly_name" />

Related

How adapt extension to Visual Studio 2019?

I read that adapting of extension for VS 2019 is quite easy - https://devblogs.microsoft.com/visualstudio/visual-studio-extensions-and-version-ranges-demystified/#.
But I got an error if I do all the actions from the post:
It's not possible to install because there is no following links:
Microsoft.VisualStudio.Component.CoreEditor.
The author of the post shows the exactly same row when he adapts his extensions:
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" />
So it seems that this prerequisite was not a problem for him.
My updated extension.vsixmanifest is:
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
<Metadata>
<Identity Id="PowerQuerySDK.Microsoft.30831070-f420-4649-a031-6f679996b182" Version="1.0.0.20" Language="en-US" Publisher="Microsoft" />
<DisplayName>Power Query SDK</DisplayName>
<Description xml:space="preserve">A Power Query language service for Visual Studio</Description>
<License>Microsoft Power Query SDK - Pre-Release or Evaluation Use Terms.rtf</License>
<Icon>dataconnector_128.png</Icon>
<PreviewImage>EATIcon.ico</PreviewImage>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[14.0,17.0)" />
<InstallationTarget Version="[14.0,17.0)" Id="Microsoft.VisualStudio.Pro" />
<InstallationTarget Version="[14.0,17.0)" Id="Microsoft.VisualStudio.Enterprise" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" Version="[4.5,)" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" Path="ProjectTemplates" />
<Asset Type="Microsoft.VisualStudio.ItemTemplate" Path="ProjectTemplates" />
<Asset Type="Microsoft.VisualStudio.VsPackage" Path="Dependencies\Microsoft.Mashup.Tools.VisualStudio.pkgdef" />
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Dependencies\Microsoft.Mashup.Tools.VisualStudio.dll" />
</Assets>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" />
</Prerequisites>
</PackageManifest>
Please could you say what may be the workaround for the problem?
I found the solution for the problem. It is in catalog.json file inside PowerQuerySdk.vsix file. You should change part of the file from:
"Microsoft.VisualStudio.Component.CoreEditor":"[15.0,16.0)"}
to:
"Microsoft.VisualStudio.Component.CoreEditor":"[15.0,17.0)"}
.
I didn't suspect that the mention of CoreEditor may be in this file. But obviously you should change the version of MSBuild to 17, just as you should do in extension.vsixmanifest, as it is described in the post of Mads Kristensen above.
Up to now all works fine for me :-).
I also ran into this issue while porting a Visual Studio Extension forward from 2017 to 2019.
The change was 2-fold:
Firstly updating the 'Installation Target' range in the 'vsixmanifest' file.
Secondly, updating the Prerequisite 'Microsoft.VisualStudio.Component.CoreEditor'
Below is an example of the Manifest file I changed.
Pull Request
Mads Kristensen's original Blog Post on forward porting Visual Studio Extensions from VS 2017 to VS 2019.

Changing from .NET 3.5 to 4.5.1 causes app not to run

I have a .NET web application that was originally running on .NET 3.5 but upgraded it to .NET 4.5.1. When I attempt to run the application, I get the following error:
Configuration Error
Description: An error occurred during the processing of a configuration file
required to service this request. Please review the specific error details
below and modify your configuration file appropriately.
Parser Error Message: Unrecognized attribute 'targetFramework'. Note that
attribute names are case-sensitive.
Source Error:
Line 63: debugging ASP.NET files.
Line 64: -->
Line 65: <compilation defaultLanguage="c#" debug="true" targetFramework="4.5.1" />
Line 66: <!-- CUSTOM ERROR MESSAGES
Line 67: Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
Version Information: Microsoft .NET Framework Version:2.0.50727.8745; ASP.NET Version:2.0.50727.8745
As you can see by the last line, this application is still using .NET Framework verison 2.0.50727.8745.
I asked my colleague to open the solution after getting it from source control and run it and it uses .NET 4.0.* and he doesn't see this error. This leads me to believe there is something wrong with my machine. I have looked in the applicationhost.config and I don't even see my application listed, much less anything regarding which .NET version it's using. Why would it work on his machine and not mine? I have a bug fix I need to implement and if I can't run the application that isn't going to happen.
Change your app pool to use v4.0 runtime. It is entirely possible that the machine it is failing on does not even have v4.0 runtime installed.
This is because of IIS Express config applicationhost.config which is located in .vs directory. It contains application pool assignment to your project:
<system.applicationHost>
<applicationPools>
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="Clr4ClassicAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="Clr2IntegratedAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="Clr2ClassicAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="UnmanagedClassicAppPool" managedRuntimeVersion="" managedPipelineMode="Classic" autoStart="true" />
<applicationPoolDefaults managedRuntimeLoader="v4.0">
<processModel />
</applicationPoolDefaults>
</applicationPools>
<sites>
<site name="YourWebSite" id="2">
<application path="/" applicationPool="Clr2IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\YourWebSite" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:46397:localhost" />
</bindings>
</site>
</sites>
</system.applicationHost>
You can change the pool your project uses... in theory. I tried but it didn't help. The working solution is to remove .vs directory and open your solution again. .vs directory will be created again with correct config.

Creating a server-level Web Deploy package

I can use Web Deploy to create packages that can be imported in existing IIS sites after the IIS server administrator manually creates the site for me.
Can I use Web Deploy to create packages that can be imported as a site instead of an application?
When I try to import my existing packages, I get this ugly error.
This might not be an answer to the question as was not able to find information on how to create a site package.
But as you asked for it in the comments, here's my approach on how to use the .cmd file created by the package process to install on site level.
Step 1
I create a package in our build process with msbuild. I've just added an extra step to our normal build that creates the project files in a deploy directory.
<Target Name="CreateDeploymentPackage">
<MSBuild Projects="$(CurrentProject).csproj" Targets="Package"
properties="Platform=$(Platform);
Configuration=$(Configuration);
DeployOnBuild=false;
DeployTarget=Package;
PublishProfile=$(Environment);
PackageLocation=$(DeployDirectory)\_PublishedWebsites\DeployPackage\$(CurrentProject).zip;
PackageAsSingleFile=true;
_PackageTempDir=$(PackageOutputDir)\temp;">
</MSBuild>
</Target>
I did set a specific PublishProfile to be able to pass a Web.config transformation for everything I know at build time.
Step 2
I've created a Parameters.xml in my project to be able to change params on install time of the package.
<?xml version="1.0" encoding="utf-8" ?>
<parameters>
<parameter name="Log4net to email"
description="Please provide the email address for Log4net."
defaultValue="itsupport#ourcompany.com"
tags="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="//log4net/appender[#name='SmtpAppender']/to/#value" />
</parameter>
<parameter name="Webservice address"
description="Please provide the endpoint address for the document web service"
defaultValue="http://test.services.ourcompany.com/Service.svc"
tags="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="//system.serviceModel/client/endpoint/#address" />
</parameter>
<parameter name="Elmah error email subject"
description="Please provide the elmah errormail subject"
defaultValue="Our Portal (Production) | An unexpected error occurred"
tags="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="//elmah/errorMail/#subject" />
</parameter>
</parameters>
You might think why there is no sitename and connection string in the Parameters.xml. But these are created automatically configurable when the deploy package is created and can be set with the SetParameters.xml
Read here: Why are some Web.config transforms tokenised into SetParameters.xml and others are not?
Step 3
Then I created a SetParameters-.xml for every environmen we have (prod, staging, test, dev). Here's one example for staging:
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="staging-sitename.ourcompany.com" />
<setParameter name="Log4net to email" value="webdev#ourcompany.com" />
<setParameter name="Webservice address" value="http://staging.services.ourcompany.com/Service.svc" />
<setParameter name="Elmah error email subject" value="Our Portal (Staging) | An unexpected error occurred" />
<setParameter name="PortalEntities-Web.config Connection String" value="metadata=res://*/Src.Entity.PortalEntities.csdl|res://*/Src.Entity.PortalEntities.ssdl|res://*/Src.Entity.PortalEntities.msl;provider=System.Data.SqlClient;provider connection string="Data Source=test.sql.ourcompany.com;Initial Catalog=Portal_Staging;User Id=<userid>;Password=<password>;Application Name ='OurPortal';Connection Timeout=180;MultipleActiveResultSets=True"" />
</parameters>
Step 4
Then I excecute the install on the server with the following command
Portal.Web.deploy.cmd /Y -setParamFile:"Portal.Web.SetParameters-STAGING.xml"
There's still a lot of room for improvement, and I would like to automate more but this is what I have right now.
Basically instead of installing at the root of the site, deploy to a folder within the site!

Visual Studio 2015 Error 500.19

I have problem with opening project in VS 2015. In VS 2012, and VS 2013 is everythink ok. But when I start web application in VS 2015, I got error 500.19 while loding css and js files.
I know, that it shoud be because of permissions, so I set NETWORK, NETWORK SERVICE and IIS_IUSRS to read, write, modify on my project folder, but it did not help.
Have anyone idea?
Finally I can handle with it. I just need to remove from my web.Config
<staticContent>
<mimeMap fileExtension=".less" mimeType="text/css" />
</staticContent >
If you want to use your mimeMap instead of the one on IIS, just change your config file to remove the existing before adding yours:
<staticContent>
<remove fileExtension=".less" />
<mimeMap fileExtension=".less" mimeType="text/css" />
</staticContent >

.NET Web Deployment Tool with log4Net: Not overwriting logs

I'm using the Web Deployment Tool to build and release an MVC site from VS 2010 to a server running IIS. I also have log4net logging to a subdirectory off of the root of the web application I'm deploying to. I already figured out how to keep write permissions intact when deploying with this tool on that directory, but now I'm running into the problem that I'd rather not lose the logs when deploying, and also, the deploy is failing because the log file that log4net is using is "used by another process" (presumably w3wp) and won't let the deploy continue.
So, I'd like to preserve the log files and not delete or overwrite them, for auditing purposes. Is there a way to do that within the confines of the Web Deployment Tool?
EDIT: Here's the applicable bits of the log4net configuration, in Web.Config.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" />
</configSections>
<log4net>
<appender name="RollingLog" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Logs\Log.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="20" />
<maximumFileSize value="10MB" />
<datePattern value="yyyyMMdd" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="{%level}%date{MM/dd HH:mm:ss} - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLog" />
</root>
</log4net>
</configuration>
Found it by hunting around: there is a "skip" parameter you can tack on to the command when you call the pre-packaged deploy script. You HAVE to use a regular old CMD prompt for this; Powershell's crazy escaping of quotes makes it near-impossible to get right, so I gave up. Anyway, here's the end result I came up with:
.\MyProject.deploy.cmd /Y /M:MyServerName "-skip:skipAction=Delete,objectName=filePath,absolutePath=Logs"
"MyProject.deploy.cmd" being the name of the prepackaged deploy command, "MyServerName" being the name of the server I was deploying to, and "Logs" being the name of the folder I wanted to skip. This command seems to leave alone that Logs directory and deploy anything else that matters.
Source where I started to hone in on things: http://blogs.iis.net/msdeploy/archive/2009/04/23/what-has-changed-about-skip-replace-rules-in-rc.aspx
Set locking model of your appender to minimal lock and everything will be fine:
<appender name="RollingLog" type="log4net.Appender.RollingFileAppender">
...
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
...
</appender>
log4net.Appender.FileAppender (see remarks)

Resources