I'm using ReSharper 5.1 and Visual Studio 2010.
If I create a new Portable Class Library project and insert the following:
using System;
public interface TestInterface<T>
{
void FindAll(Func<T> f);
}
ReSharper highlights the reference to 'Func' as an ambiguous reference. Selecting 'Go to declaration' takes me to a choice of
public delegate TResult Func<out TResult>(), from mscorlib 4.0.0.0
or
public delegate TResult Func<TResult>(), from System.Core 2.0.5.0
However, the C# compiler builds this code successfully. Suspending ReSharper and selecting 'Go To Definition' indicates that the actual definition being picked up is from System.Core.dll, v4.0.30319
Why is ReSharper getting confused?
The problem does not happen using a standard C# class library project type, only with a portable class library project type.
I noticed this problem while examining the source code of the C5 Generic Collection Library
for C# and CLI
Related
There are different types of Class libraries available in Visual Studio such as Silverlight Class Library, Portable Class library and Class Library. What are the differences between these types? How can we determine the type of a Class library with File.dll file? How can we change a Class library from own type to another type of Class library?
The Portable Class Library project type enables you to write and build managed assemblies that work on more than one Microsoft platform, whereas the "normal" Class Library project type doesn't.
"Microsoft platforms" include .NET Framework, Windows Phone, .NET for Windows Store Apps, Silverlight, Xbox; all in various versions or flavors.
Source
Go through this for converting from one class library to another type. (See also: this relevant SO question.)
I'm beginning my first explorations into Silverlight RIAs and EF4, but I can't get a project to run right off the templates that ship with VS2010 SP1.
Bear in mind here that what I've done is to install a brand new Windows 7 VM, and then I immediately installed LightSwitch Beta 2. Following that, I added VS2010 Premium, and applied Service Pack 1 to that.
The client portion of the Template app is kicking off three warnings and two errors; the details are posted below. It's looking for a WebContextBase class that it can't find, in code that it generated into Web.g.vb (and Web.g.cs) files. So far this project is entirely generated off the solution template; I haven't added a single line of code to what VS2010 generated.
I've since gotten EF4 to work fine in WinForms projects and Light Switch projects.
What's going on here, and how do I fix it?
------ Build started: Project: EF4Test, Configuration: Debug Any CPU
------ C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(21)
: warning BC40056: Namespace or type
specified in the Imports
'System.ServiceModel.DomainServices'
doesn't contain any public member or
cannot be found. Make sure the
namespace or the type is defined and
contains at least one public member.
Make sure the imported element name
doesn't use any aliases.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(22)
: warning BC40056: Namespace or type
specified in the Imports
'System.ServiceModel.DomainServices.Client'
doesn't contain any public member or
cannot be found. Make sure the
namespace or the type is defined and
contains at least one public member.
Make sure the imported element name
doesn't use any aliases.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(23)
: warning BC40056: Namespace or type
specified in the Imports
'System.ServiceModel.DomainServices.Client.ApplicationServices'
doesn't contain any public member or
cannot be found. Make sure the
namespace or the type is defined and
contains at least one public member.
Make sure the imported element name
doesn't use any aliases.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(34)
: error BC30002: Type 'WebContextBase'
is not defined.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(65)
: error BC30451: 'WebContextBase' is
not declared. It may be inaccessible
due to its protection level.
Have a look at LightSwitch Beta 2 Readme
There are few know issues with the LightSwitch. From the steps you have described to setup your system I would guess that the problem could be because
"2.1.1 Visual Studio 2010 users or
Visual Studio 2010 SP1 Beta1 users
must install Visual Studio 2010 SP1
before installing Visual Studio
LightSwitch Beta2"
You should try uninstalling LightSwitch Beta2 and then reinstall, and let us know if you get the same error.
Hope this helps.
Include this reference..
System.ServiceModel.DomainServices.Client.ApplicationServices
I'm getting a build error in Visual Studio that's not making any sense:
The type or namespace name 'MyService' does not exist in the namespace 'My.Project' (are you missing an assembly reference?)
The namespace MyService is defined in a Web Reference. In the Object Browser, I can clearly see that namespace and all of the classes defined in it. There are no compile errors for any of the code in the Web Reference.
The code stopped compiling after I changed the framework target from 2.0 to 3.5. Why could the compiler be choking, and how can I go about fixing this? I already tried updating the web reference, but the problem remains. I even tried commenting out the code in the generated "Reference.cs" and copying the code to another code file in the project, and the namespace was still not seen.
My project is referencing the following:
System 2.0.0.0
System.Data 2.0.0.0
System.EnterpriseServices 2.0.0.0
System.Net 3.5.0.0
System.Web.Services 2.0.0.0
System.Xml 2.0.0.0
Update
It isn't just my web service generated code that is having compile problems; for all of the projects converted to .NET 3.5, I cannot reference their namespaces.
I'm still not sure why this is all happening, but I found a workaround; by adding a using Ns = My.Project.MyService to my code, I was able to reference types in the namespace with Ns.MyType.
This is apparently documented as a bug in Visual Studio:
https://connect.microsoft.com/VisualStudio/feedback/details/570557/targeting-net-framework-3-5-actually-targets-3-0-gac
I utilized the workaround documented in the post by copying System.Web.Extensions.dll from C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5 to C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0. Then I restarted Visual Studio.
That alone didn't fix the problem. I had to redo the project conversion from 2.0 to 3.5 after the assembly was copied. After the new conversion, the code compiled as expected. Doing a diff between the project file pre- and post-workaround didn't reveal any substantial differences, so the build errors must have been due to some internal state of Visual Studio.
I have a project called ManagedWrapper that is Managed C++ and builds as a DLL.
I have a second project called MyManagedTest that is Managed C++ and builds as a DLL.
When I try to include a header from ManagedWrapper in MyManagedTest, I get linker LNK2020 errors. I then add a reference to ManagedWrapper in "Frameworks and References" but this causes compiler errors saying that classes in ManagedWrapper are already defined (looks like it is trying to define them again in MyManagedTest because I included header files), error C2011.
What is the proper way to include classes from ManagedWrapper into MyManagedTest?
Thanks.
You should use #include for native class declarations and #import for managed class declarations. Adding a reference is the same as #import.
BTW, "Managed C++" is not the correct name for using C++ with .NET in VS2008. That feature is C++/CLI. Earlier versions of Visual C++ had a very buggy syntax called "Managed Extensions for C++" which was often referred to as "Managed C++" and should never be used.
I have a class diagram associated to a Silverlight class library project in Visual Studio 2008 SP1. One of the pieces of code displayed in the diagram is an interface I have made that inherits from System.Windows.Input.ICommand.
Now I want the base class of that interface (ICommand) to be shown in the diagram as well. So I right-click in the box representing the inherited interface, and select Display base interfaces. Then Visual Studio shows the following error:
Can't display one or more base types because the following type can't be found: System.Windows.Input.ICommand
The System.Windows assembly is properly referenced, the code for the inherited assembly has no errors, and the project compiles without problems.
So, what's happening here? Maybe a bug in Visual Studio?
To try to reproduce the error I have done the following (don't mind the naming of my objects):
create an Interface (ICompany) and inherit from System.Windows.Input.ICommand
create an entity (Company) that implements my interface
create a class diagram and added my interface and class
right clicked my interface and selected show interface
I'm using Visual Studio 2008 with the latest SP installed and I don't seem to get the error. Do I do something different then you?
Is your diagram located in your SL app/lib or in your Web app?