Visual Studio 2017 project reference support between .net standard and .net core - visual-studio

I have a .Net standard 2.0 project in a Visual Studio solution that contains some Azure functions. In the same solution, I've created a .Net Core 2.0 Unit Test project. I've added a project reference from the .Net Core Unit Test project to the .Net standard 2.0 library.
Despite the project reference, Visual Studio is behaving like I'm referencing a dll instead of the project. For example, if I try to use F12/Go to reference, it brings me to a 'From metadata' file instead of the actual code file in the other project. Additionally, codelens features like 'Tested by' (and even just 'referenced by') and the Live Unit testing icons in the .Net Standard project aren't working, since they don't seem to be aware of the Unit Test project at all.
Is there some way to get this integration working between the two projects? My Visual Studio is up to date (15.5.3 enterprise), and I'm not using any tools like Resharper or anything like that.

I'm also facing the same issue but so far the project reference vs dll reference is not the case. I believe this is an existing issue with Azure function projects. There is a thread in Microsoft community regarding this issue. The last comment from Visual Studio is as follows:
I'm closing this report, because in the last 90 days there was no internal developer activity and very small number of new votes or comments. Sorry, we would like to look at this further, but we just don’t have the time right now. Our goal in closing older issues such as this one is to keep customers informed on which issues are currently being pursued by Visual Studio teams. If you still have trouble with our latest version, please report it as a new problem.

Related

Shared Project option totally gone from the Xamarin.Forms project menu in Visual Studio 2019?

I work with Xamarin.Forms in Visual Studio since a few years, and updated my IDE recently (VS v. 16.3.7). Now I realized something is missing: the Shared Project option.
When i go through the Wizard to create a new project the question if I want to use Shared Project or PCL(or NetStandard) is now missing (see screenshot below from VS 2017)
I do know that you can still create a Shared Project and add an iOS and an Android project manually, but this is just too cumbersome. My question really is: Is there a reason why Microsoft went on to push the PCL/NetStandard above the Shared Project strategy?
I am specially confused about this decision since already back in 2016 #miguel.de.icaza declared his favorite option (for most cases) was the Shared Project strategy:
https://tirania.org/blog/archive/2016/Jan-22.html
For me, the PCL is just too cumbersome for most uses. It is like using a canon to kill a fly. It imposes too many limitations (limited API surface), forces you to jump through hoops to achieve some very basic tasks.
I have installed VS 2017 15.9.14, on this version, Portable Class Libraries (PCLs) are deprecated. You could use .NET Standard instead. On VS 2019, the default is .NET Standard.
On Microsoft document, MS recommend .NET Standard 2.0 libraries over Portable Class Libraries.
For more, please refer to the MS docs. https://learn.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/code-sharing
My question really is: Is there a reason why Microsoft went on to push the PCL above the Shared Project strategy?
For MS announcement, PCL is deprecated, you could not find that when you create the project.
You could create the Shared project by File > New > Project > Shared Project template.
For more details, you could check the link below. https://learn.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/shared-projects?tabs=windows
Updated:
Is there a reason why Microsoft went on to push the >NetStandard< above the Shared Project strategy?".
For the old version of VS 2017, .Net Standard is an option of Shared Project strategy.For the latest version of VS, MS use .Net Standard as the default for Sharing Strategy.
Is there any doc where MS states why Shared Project is now deprecated/not available in the Xamarin.Forms project wizard?
PCL is deprecated. Shared Project is still in use, in my answer, I provide the second link about how to create the shared project.
Summarizing and adding to the answer by #WendyZang-MSFT:
I started a project using the Shared Project strategy around 4 years ago, and until now i have not found any issue/problem specific to it that would make me consider moving to .Net Standard.
Recently i went into the trouble of localization, and even that was possible using Shared Project without much hassle.
As mentioned above, after i saw that the latest version of Visual Studio 2019 was not offering the possibility of creating a Xamarin.Forms App as a Shared Project i got a bit worried thinking that i should migrate my solution. But the time hast passed by, and i just realized that MS encourages the use of .Net Standard, but Shared Project remains also a valid approach.

Developing in Visual Studio 2010 and Sharepoint 2007. Using new SPSite throws errors

I'm re-writing a console application using Visual Studio 2010. The original application was written using Visual Studio 2008 and works OK, but has no tests associated with it. Hence, the idea of re-writing it with tests.
Both applications are working with a Sharepoint 2007 site.
The project compiles but when I try and run it the code below is throwing errors.
SPSite spsite = null;
SPSecurity.RunWithElevatedPrivileges(delegate() {
spsite = new SPSite("http://sharepointdev");
});
return spsite;
I'm running this on Windows Server 2008. I've set the platform target of the build to be x86 (this is in the properties of my project) and in Security I've checked that this is a full trust application. I'm also running the project as an administrator. I've also set the .NET Framework to be 3.5
Is it just a case that SharePoint 2007 just doesn't want to play with Visual Studio 2010, or is there something else I've not yet considered?
I've tried searching on the web and stackoverflow but all the articles I've seen deal with trying to get Visual Studio 2010 to work with Sharepoint 2010.
The exact error I get is 'Object reference not set to an instant of an object' with the debugger high-lighting the SPSecurity call.
If I just use this code
using(SPSite spsite = new SPSite("http://sharepointdev")){
Then I get a FileNotFoundException, which isn't exactly true! I've got plenty of applications that do find a site using that URL. What I suspect the error message is trying to say is that my 2010 application is not being allowed to access the site, but I've not found any clues as to why that should be.
Any clues, hints or suggestions gratefully accepted.
EDIT
I've lifted the code from my VS 2010 project and dropped it into a new VS 2008 project and it ran straight-away.
FURTHER EDIT
I created a simple little console application in VS 2010. By default it uses .NET Framework 4, I had to set this to .NET Framework 3.5. I also set the platform target to be 'Any CPU' and it works. This makes me wonder if there is an issue with the Test Project associated with my first application?
I re-created the console application but this time without a Test Project associated with it (the test project was a class library and worked with NUnit). It ran with no problems. I guess the problem lies within the test project and something there that the solution doesn't like. Probably there's a build there it doesn't like
TL;DR; answer: Switch to Any CPU build - don't choose x86.
I've run into this problem before with a console utility. I got the same FileNotFound error but it's referring to the DLL, not your SharePoint site. Digging a bit I discovered a deeper error of BadImageFormat and realized it was complaining about a DLL or EXE. I guessed it was due to the linking from x86 to MSIL. There's a lot of things that have to happen to marshal calls between the two and I guess it led to an incompatibility. When I switched it (and verified all my support library projects) built to MSIL/Any CPU the application worked with no problems and no other changes.
I use Visual Studio 2010 to develop for SharePoint 2007 all day for a long time now and the only problems I've encountered aren't related to that combination. More often than not it's a quirk of a 3rd party add-on I'm using. For almost all of my development I start with the WSP Builder templates but they are buggy and have a few quirks you have to work around (some severe enough to take down your SharePoint server) so I don't blame VS 2010 directly.

Using VS 2010, can I reference a project created in VS 2005?

Here's a puzzler - something that doesn't work that I assumed would (no surprise there).
We have a library project that is referenced in a few other desktop app projects. The library project is written in VS 2005 (.NET 2.0).
My problem is that some of our apps still live in VS 2005 for the time being (for various reason). I can't seem to reference this library project in VS 2010 without it demanding that I upgrade it to .NET 4, which if I do, then breaks my ability to include it as a reference in my VS 2005 projects.
This type of thing fries my brain. Is there any way I can make this work?
Hmm, that doesn't make a lot of sense. You don't reference a 'library project', you reference the DLL that it produces. Project + Add Reference, Browse tab. There's no known problem with that, within a 95% accuracy guess, mixed mode assemblies have a few hairs.
If you actually try to load a vs2005 project into a vs2010 solution, then yes, it's going to try to convert the project file. And that turns vs2005 catatonic, it doesn't have the time machine to guess what a vs2010 project looks like. Just making a copy of the project directory solves that problem.
Can you change the .NET version back to 3.5 or 2.0 in VS.NET 2010 after it revises the project version to .NET 4.0?
Use a file reference to the built dll, rather than a project reference.
You may also find you need to add an extra bit of compatible-framework info to your manifest file to tell .net to allow your .exe to use .net 4 and .net 2 assemblies alongside each other - if it's not there you'll just get an error on startup. (Sorry, I can't remember the exact details and I'm not at my work machine right now to be able to find them - but if you have problems at runtime, the error message should lead you to the exact solution you need)
Correction: I was thinking of this 'useLegacy' startup setting, which you may need to add to your app.config if you want to use a mixture of .net 2.0 and .net 4.0 assemblies in your application:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
On option, that is a complete PITA, but should work is:
Create a new project file in 2010 that includes everything the 2005 project file has. Just call it MyProject2010.csproj or whatever.
Then, add this project to your 2010 solution.

How can I choose which version of the CLR my tests will run under in Visual Studio?

I'm using Visual Studio 2010 and both the assembly under test, and the assembly containing the tests target version 3.5 of the .NET framework (that corresponds to the v2 CLR).
The problem is that, when I created the test project, even though I choose version 3.5 to target, Visual Studio added a reference to the v4 Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly. I guess this is forcing the tests to run under the CLR 4.0.
I wish I could just ignore this issue, but there is some quirky COM interop behavior (probably the COM component's fault, over which I have no control whatsoever) when running under the v4 CLR.
I tried adding the test framework reference by hand, but I couldn't find it. Does it even ship with VS10?
Is there anything I can do, besides running these tests "manually" in a dedicated v2 console application?
This is a known issue that will be resolved in the upcoming Service Pack 1 for Visual Studio 2010 (see bullet on Unit Testing on .NET 3.5). The SP is still in Beta. As far as I know, a final release date hasn't been announced.

What to look out for when moving from Visual Studio 2005 to 2008?

We're planning on updating our developers from Visual Studio 2005 to 2008. Are there any common "gotchas" to look out for during this move?
My major concern at the moment is that we use WSE 3.0 quite a bit (mostly to consume external .asmx web services, but we also host a few ourselves). Will that be an issue since WSE 3.0 has been replaced by WCF?
Additional background info: VB.NET application with several web sites, not web applications. Currently using .NET 2.0 with plans to upgrade to 3.5 soon as well.
Anything else we should be concerned about?
I think the main issue you have to watch out for is upgrading teams. Once you upgrade to a new version of Visual Studio, you will be forced to upgrade your project files as well. Once the upgrade is complete the file will no longer be compatible with previous versions of Visual Studio. This means that you will break anyone who is using the previous version of VS to develop. The best advise is to upgrade the entire team.
The best way to work around this is to keep 2 versions of the project file around. One for the previous version of Visual Studio and the other for the current. This obviously has a bit of overhead. And Once you actually start using new language features this will no longer be a sufficient as the new features likely won't compile in the old versions of Visual Studio.
The changes in the visual editor for things like ASP.NET projects (especially when it comes to styling elements) is very different and can be incredibly frustrating at first.
I've found VS05-08 migration pretty painless. In theory, you should be able to simply open the 2005 solution in VS2008, let it convert, and everything just works. VS2008 lets you 'target' a specific version of .NET, and the default here would be that it continues to target .NET 2.0. That said, 3.5 is an additive update, so there should be little or no breaking changes to any .NET 2.0 code should you change to 3.5 (which is just a drop-down-box to change). I'm pretty sure the WSE stuff should "just work".
In practice, things like project templates, dependencies, etc. could be an issue. Web sites and web applications are still both supported, so I think that shouldn't be an issue either.
In the end, just make a backup of everything, then open in VS2008 and see what happens.

Resources