I have a project that uses the Enterprise Library 4.1. When I target .net 4 and compile, I get an error that says I need to add a reference to System.ServiceModel version 3. My reference is to System.ServiceModel version 4. How can I tell Visual Studio 2010 to reference a .net3 assembly from a .net3 project? Or, does somebody have a workaround for this issue?
I am using the RTM version of VS2010
Thanks
Some references in the csproj file (e.g. System.ServiceModel in ExceptionHandling.WCF project) have the SpecificVersion property set to True.
You can right click on this reference and choose Properties and change this value to False. Alternatively you can edit the csproj file in notepad and change <SpecificVersion>True</SpecificVersion> to <SpecificVersion>False</SpecificVersion> for this reference
Related
I'm using Visual Studio 2022. I have created a .net 6 project.
I added the COM references: Microsoft Excel 16 Object Library (Microsoft.Office.Interop.Excel) and Microsoft Office 16 Object Library (Microsoft.Office.Core).
The following lines of Excel interop code threw an error at SetElement(), could not build:
Chart c = (Chart)wbSheets.Application.Workbooks[1].Charts.Add();
chart.SetElement(Microsoft.Office.Core.MsoChartElementType.msoElementChartTitleAboveChart);
Microsoft.Office.Core... is defined in an assembly that is not referenced. You must add a reference to assembly office, Version=15.0.0.0, ..., PublicKeyToken=71e9bce111e9429c
A very strange error, that an Office 16 (Office 2016) libary needs references to Office 15 (Office 2013).
The exact same steps for COM referencing and c# code works perfectly in .NET 4.8 Framework. So the problem is specific to .NET 6 (possibly .NET 5 and all previous .NET Core versions).
Using a nuget command Install-Package MicrosoftOfficeCore -Version 15.0.0 to install the reference and manually removing the previous v16 reference, did resolve the code building error. But now the dependency had a yellow triangle warning, that the dependency is for .NET 4.6-4.8 Framework and might be incompatible with .NET 6.
Despite this, the code seemed to work and the Excel file was generated.
But I'll post a better fix in the answer.
The better fix is to go to:
Solution Explorer > project > Dependencies > COM > select Microsoft.Office.Core > properties pane.
The last property is Wrapper Tool, with a default value of tlbimp
Type in primary for the value, click somewhere else to update the field and the problem is solved. No nuget package required.
Found this obscure solution from here (bottom most post):
https://github.com/dotnet/project-system/issues/5735
I have a new instance of Sitecore 9. I'm trying to create my first component, an ascx file with a codebehind file, and I have this line:
var item = Sitecore.Context.Item;
The build is failing with the error "The name 'Sitecore' does not exist in the current context"
please make sure that you have added the reference to "Sitecore.Kernel.dll". i would suggest you to also checkout the nuget packages provided from Sitecore:
Sitecore Nuget Feeds
Depending on your deployment Strategy it would be a good practice to use the nuget. Sitecore has created every nuget package with ".NoReferences" extension for example : "Sitecore.Kernel.NoReferences" which is great for dependency management.
If you are using MVC you will need also "Sitecore.Mvc.dll".
In my case, I had a error specification in the output window for this error which turned out to be an hint to solve this error.
The .NET framework version of my visual studio project was targeted at v4.6.1, updating the project's target framework to v4.6.2 fixed my error : "The name 'Sitecore' does not exist in the current context"!
It seems that the Sitecore.kernel.dll (responsible for using term 'Sitecore' for reference in code like controllers) with version 11.1.0.0 was built against the ".NETFramework,Version=v4.6.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6.1" (of my visual studio project).
Here is the error specification (hint!) in my VS output window that I mentioned earlier:
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3274: The primary reference "Sitecore.Kernel, Version=11.1.0.0, Culture=neutral, processorArchitecture=MSIL" could not be resolved because it was built against the ".NETFramework,Version=v4.6.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6.1".
I am having some serious issue when migrating Coded UI test from VS2010 to VS2012. The issue is related to assembly reference. I try to reference the new 11.0 version CodedUI assemblies, but the system keeps looking for the old 10.0 version when VS2012 tries to find all the cases and list in the Test Viewer. Such as:
'Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I found this MSDN link: http://msdn.microsoft.com/en-us/library/tfs/hh506981(v=vs.110).aspx
It mentions some issue related to assemlby reference. But I don't understand the following quotation:
In Visual Studio 2010, references were added inside a ‘Choose’
statement in the csproj file. In Visual Studio 2012, we are using
a Feedback targets file to include Coded UI Test Assembly references.
What is a Feedback targets file??
I've covered your problem with the answer in this blog post.
You need to open your proj file and check for the logic that has been added to reference properly the version 11.0.0.0 of the testing tools assemblies.
I presume the feedback targets file is the imported msbuild file in the VS 2012 folder for msbuild targets. It is an implementation detail, all you need is to focus in upgrading your project file according to what the "repair" wizard is supposed to do, I give precise steps in my post.
Regards and good luck (if I'm not too late)
I have project that have to be build with different framework versions including .net 1.1.
To build project with .net 1.1 I need to change Project's ToolsVersion to 2.0, but for other frameworks it must be set to 4.0
Is it possible to implement such behavior in Visual Studio?
Something like this in csproj file:
<Project ToolsVersion=" if $(Configuration) == DOT_NET1_1 THEN '2.0' ELSE '4.0'">
No. The ToolsVersion attribute is set automatically by the version of Visual Studio used to open the project file. The properties that the ToolsVersion controls are reserved and cannot be modified by msbuild. I don't have experience with compiling in .NET 1.1, so I don't know if this is the most elegant solution, but:
In lieu of constantly changing this attribute, the only thing I can think of is to create two different project files, one for compiling in .NET 1.1 and the other for compiling in the other frameworks. They can both reference the same source files, referenced dlls, etc, just be sure not to have them in the same solution, or Visual Studio 2010 will try to upgrade the project file with the older ToolsVersion.
I am trying to go through the example at http://msdn.microsoft.com/en-us/library/aa719643(VS.71).aspx
Visual studio 2010 does not recognize System.Web.SessionState and various others.
I tried adding a .net reference to them but they do not exist on my system. I have .Net 4 installed.
Why would these examples use namespaces that are not recognized by visual studio?
alt text http://www.phantix-llc.com/system.web.sessionstate_missing.jpg
System.Web isn't shown because VS2010 defaults to using the .NET4 Client Profile which doesn't include it. (You can see the "Filtered for .NET Framework 4 Client Profile" text at the top of the Add Reference dialog.)
You need to change your project's properties so that it targets the full version of the framework, then you'll be able to select System.Web.
System.Web.SessionState (and the others shown unrecognized) are in System.Web.dll. Verify that reference exists.