Error debugging unit test in VS 2013 using Resharper - c#

I am trying to debug a nunit unit test using Resharper in Visual Studio 2013.
I can run the test successfully although when I attempt to debug the test inside VS using Resharper I get the below warning msg.
"Microsoft WCF Service Host"
"The target assembly contains no service types. You may need to adjust the Code Access Security policy of this assembly."
The test does not fail and Visual Studio said it is "Running" although no break points are hit (in the test) nor does it throw any kind of exception or error.
Has anyone encounter this and know what a solution is?

Found the answer for anyone else interested.
How can I get rid of the "The target assembly contains no service types" error message in VS2008?
I had 1 project in a solution of around 90 which had the WCF Option enabled.

Related

XSP/Mono: preventing "Warning as Error" exceptions

I'm running an ASP.NET v4.8 project under Mono.
Actually, I'm doing it by using the Mono's standalone web server - XSP.
When I try to start the application in browser, I'm getting this annoying exception:
System.Web.Compilation.CompilationException:
error CS1685: Warning as Error: The predefined type System.Runtime.CompilerServices.AsyncMethodBuilderAttribute' is defined multiple times. Using definition from mscorlib.dll'"
For each project in my solution, I set the "Treat warnings as errors" option to "None" - but it still doesn't work.
I suspect that the "Warning as Error" exceptions come from the XSP program, but not sure.
I can say that I able to load the application when I'm deleting 2 files - System.Memory.dll and System.Threading.Tasks.Extensions.dll which both are used by npgsql.dll.
But when I try to use Postgres in the application, I'm getting another exception which says that the 2 files are missing...
Since the project works fine on IIS, my question is:
how do I stop those annoying "Warning as Error" exceptions?
Thanks for any answer!

Weird error: Microsoft (R) Visual C# Compiler version 3.5.0-dev-20359-01 (8da8ba0c)

I have a Unity 2020.3.22f1 project that was perfectly working at first. However, this error occured after editing and saving one of my scripts in Visual Studio (with no apparent bug in it):
I don't give details about my script or the project, because it doesn't seem to relate to the project itself or what I did, as the error appears now in all my Unity projects! I first tried to delete the script that triggered the bug, then I deleted the whole project. I even uninstalled/reinstalled Unity (different versions), Visual Studio and Unity Hub. But it seems that now I'm stuck with this forever.
Does anyone have a single clue about this? I saw one or two people having the same problem on the web, and with no other solution than formatting the hard drive. As I'm not working on my personal computer, I can't do that...I mean, there must be a rational explanation to this bug!!
I downloaded the latest version of Unity (2021.2.2f1), launched a brand new project, and the error now turned to: "The specified path can't be found" (rough translation from french), without more precision...still no idea what it means.
Ok, I found a solution from here: Unity 2019.3.0a7: Microsoft Visual C# Compiler Errors
I don't know how it's related, but it is suggested that the error can be triggered by uninstalling Anaconda and Python (which I happened to do recently), which leads to remaining artifacts in the Windows registry. I then deleted the following item in the Windows registry:
Computer\HKEY_CURRENT_USER\Software\Microsoft\Command
Processor\AutoRun
and restarted Unity. Now it works!
Got the same issue, the problem is in an incomplete path
Command line is : "C:\Program Files\Unity\Hub\Editor\2022.1.0a13\Editor\Data\Tools\netcorerun\netcorerun.exe" "C:/Program Files/Unity/Hub/Editor/2022.1.0a13/Editor/Data/Tools/ScriptUpdater/ApiUpdater.MovedFromExtractor.exe" "Library\Bee\artifacts\mvdfrm\UnityEngine.LocalizationModule.dll_9374ECE80455BEFE.mvfrm" "C:\Program Files\Unity\Hub\Editor\2022.1.0a13\Editor\Data\Managed\UnityEngine\UnityEngine.LocalizationModule.dll"
Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\damos\project name is missing here\Library\Bee\artifacts\mvdfrm\UnityEngine.LocalizationModule.dll_9374ECE80455BEFE.mvfrm'.
This path is missing the project name between damos ans library

Loading projects using Microsoft.VisualStudio.LanguageServices throws System.ArgumentNullException for Visual Studio 2017

I am trying to enumerate all projects of a solution using Microsoft.VisualStuio.LanguageServices.
This is working fine for VisualStudio 2019 but it is failing on VisualStudio 2017.
My code is as bellow-
var workspace= ComponentModel.GetService<Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace>();
var projects = workspace.CurrentSolution.Projects;
I am getting exception in the second line -
System.ArgumentNullException: 'Value cannot be null. Parameter name: source'
It shows list of projects on debug though.
I am using Microsoft.VisualStudio.LanguageServices.dll of 2.10.0.0 version which is same as loaded dll in VS module.
Is it a assembly issue? How can I fix this?
This issue happened due to mismatch versions of Microsoft.CodeAnalysis between referenced dll and VS2017's dll.
In the module window it was clearly visible that, VS is using Microsoft.VisualStudio.LanguageServices 2.10.0.0, hence I kept the reference dll of same version.
In this statement-
var workspace= componentModel.GetService<Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace>();
workspace is of type Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace.
But when we do this - var projects = workspace.CurrentSolution.Projects;
the type of variable 'projects' is IEnumerable<Microsoft.CodeAnalysis.Project>
I suppose, that is the reason while debugging the value was available in quick watch but failed in to execute.
Solution - refer dlls of same version as referred by VS.

Running CodedUI Test From Another Application

I'm planning to run my coded UI test from another project (in same solution). I added a reference of the CUIT project to my winform app project. Also I added these references as well
Microsoft.VisualStudio.TestTools.UITesting.dll
Microsoft.VisualStudio.QualityTools.CodedUITestFramework.dll
Microsoft.VisualStudio.TestTools.UITest.CodeGeneration.dll
Microsoft.VisualStudio.TestTools.UITest.Framework.dll
Microsoft.VisualStudio.TestTools.UITest.Playback.dll
My code is something like this
Playback.Initialize();
TestProject.CodedUITest1 coded = new TestProject.CodedUITest1();
coded.CodedUITestMethod1();
Playback.Cleanup();
However, I get an exception on the Playback.Initialize() call.
this is the message...
"An unhandled exception of type 'Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException' occurred in Microsoft.VisualStudio.TestTools.UITesting.dll"
Someone said that installing Test agent 2010/Test agent10 can solve this error.
I installed MS Visual studio Test Agent 2010, but same error happens.
What am I doing wrong here?
Thanks
I tried to run the test the same way you do and it worked for me.
Below are the reference dlls I have added in my projects
Please make sure you have added all the dlls. In case you are not able to find the dlls, look for them in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies.
If this doesn't work please provide the details of inner exception.
I found an answer to my problem. I found that the message of the inner exception is
"Retrieving the COM class factory for component with CLSID {27876903-E697-4406-BF49-1B8B92CB8735} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."
After digging around I found that I have a 32 bit third party dll which I'm running on my 64-bit machine. The conflict is 64 bit process trying to invoke 32 bit process in 64 bit machine.
The solution is to change the project properties to target to 'X86' machine instead of 'Any'.

TeamCity "Cannot resolve symbol" in Code Inspections .NET

We are running TeamCity 10.0.1.
The build steps for our project include the step "Inspections (.NET)", which is supposed to run the resharper code inspection.
The build itself and the unit tests are all succeeding but the result of the Inspection shows a lot of errors:
4: Cannot resolve symbol 'Drawing'
141: Cannot resolve symbol 'Image'
154: Cannot resolve symbol 'Bitmap'
155: Cannot resolve symbol 'Graphics'
[...]
This is obfuscating the real issues we should address.
Does anybody know why the inspections show this kind of error although the build is succeeding and how i can fix this?
I had this problem with the code inspection at TeamCity 10.0.2 after installing the latest "JetBrains Resharper Command Line Tools" - 2017.2.2.
Using the previous one version
and assigning it to the build step
helped.
It seems that TeamCity 10.x can't work well with the 2017.xxx R# command line inspection tool. Maybe some parameters are not well passed....(?) I guess that upgrading to the TeamCity 2017.xxx and using the R# command line inspetion tool of a version 2017.x would solved the problem too.

Categories