CA1017 ComVisible related errors with VS2010 StyleCop - c#

I have CA1017 error message with StyleCop saying I need to make it ComVisible false.
Error 18 CA1017 : Microsoft.Design :
Because 'NationalInstruments.Labview.FPGA.ModelsimCommunicator.dll' exposes externally
visible types, mark it with ComVisible(false) at the assembly level and then mark all
types within the assembly that should be exposed to COM clients with ComVisible(true).
Then, I put the code [assembly: ComVisible(false)] before the topmost namespace. However, I still got the same error together with other error messages.
Error 19 The type or namespace name 'ComVisible' could not be found (are you
missing a using directive or an assembly reference?)
Error 20 The type or namespace name 'ComVisibleAttribute' could not be found (are
you missing a using directive or an assembly reference?)
It seems that VS2010 also doesn't recognize this name.
What's wrong with this?

The ComVisibleAttribute is defined in the System.Runtime.InteropServices namespace.
So you either need to:
Fully-qualify the attribute's name with its namespace:
[assembly: System.Runtime.InteropServices.ComVisible(false)]
Add a using directive to the top of your source file to import the namespace for that file:
using System.Runtime.InteropServices;
In the future, you should be able to get Visual Studio to warn you about these things. When you see a squiggly line denoting a compiler error, look for the drop-down button that's nearby or press Ctrl+. A menu should appear, indicating possible solutions for the problem. In this case, it would have suggested that you take either option 1 or 2 listed above, and with a single click, would have performed all of the necessary actions for you.
(The above amazing animated image was ripped from here.)

Related

error CS0234: The type or namespace name does not exist in the namespace (are you missing an assembly reference?)

I have seen so many QA about this error, but none of them solved my issue,
Here we go:
I have this namespace: Microsoft.MixedReality.Toolkit.SpatialAwareness.Processing
Which is included in a DLL called: Microsoft.MixedReality.Toolkit.PlaneFinding
Now, there is a second DLL called Microsoft.MixedReality.Toolkit.SDK
Which is referencing the first DLL, and also defines a constant called PLANE_FINDING_PRESENT the somehow relates to it (Here are some photos from the inspector and VS to show what i mean)
Inside of the DLL called Microsoft.MixedReality.Toolkit.SDK there is a file called SurfaceMeshesToPlanes
In this file i am attempting to be using the namespace Microsoft.MixedReality.Toolkit.SpatialAwareness.Processing like so:
I am expecting this whole thing to work but i am getting error:
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation#2eb95bb1aae9-1646916095499\SDK\Experimental\SpatialAwareness\SurfaceMeshesToPlanes.cs(13,55): error CS0234: The type or namespace name 'Processing' does not exist in the namespace 'Microsoft.MixedReality.Toolkit.SpatialAwareness' (are you missing an assembly reference?)
Any thoughts?
The problem was in the platforms section in the desired dll, once i changed it to any it became visible to the other dll

C# - Recompiling old code, running into errors (are you missing an assembly reference?)

First and foremost, I've never worked with C#, or any compiled language for that matter. So I'm hoping I'm just doing something wrong here.
We have an old in house app, written in c# that has some smtp settings hard coded that need to be changed. I have the source files, and even the .sln visual studio project file. So I open the project in vs, make the required changes, and go to build- however I'm running into errors (Build -> Build 'Autodocs' (the name of our app)):
Build started...
1>------ Rebuild All started: Project: AutoDocs, Configuration: Debug Any CPU ------
1>C:\shared\New folder\AutoDocs\Microsoft\Office\Interop\Word\Documents.cs(10,38,10,54): error CS0234: The type or namespace name 'CustomMarshalers' does not exist in the namespace 'System.Runtime.InteropServices' (are you missing an assembly reference?)
1>C:\shared\New folder\AutoDocs\AutoDocs\modules\DWStorer.cs(7,7,7,15): error CS0246: The type or namespace name 'DocuWare' could not be found (are you missing a using directive or an assembly reference?)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
So does anybody have any suggestions for a c# newbie like me? Anything I should have to do when copying a project dir from the server to my pc to build it?
Thank you in advance.
Do you know what kind of program it is? Windows? ASP.NET? MVC?
The errors are shown, but let's go through them:
1>C:\shared\New folder\AutoDocs\Microsoft\Office\Interop\Word\Documents.cs(10,38,10,54):
error CS0234: The type or namespace name 'CustomMarshalers' does not exist in the
namespace 'System.Runtime.InteropServices' (are you missing an assembly reference?)
First, look in this document:
C:\shared\New folder\AutoDocs\Microsoft\Office\Interop\Word\Documents.cs
Somewhere in that file, when viewing in Visual Studio, you will see the word CustomMarshalers, and it needs to be referenced.
So, in your project, you will need to right-click the References section and add that missing reference (if it isn't there already):
Also, at the top of your Documents.cs file, you need to have a line like this:
using System.Runtime.InteropServices;
See Microsoft's documentation here: System.Runtime.InteropServices.CustomMarshalers
Here is your second error:
>C:\shared\New folder\AutoDocs\AutoDocs\modules\DWStorer.cs(7,7,7,15):
error CS0246: The type or namespace name 'DocuWare' could not be found
(are you missing a using directive or an assembly reference?)
Similar to the first error, this one is having an error in the DWStorer.cs file because it cannot resolve the keyword DocuWare.
DocuWare is a third party tool that must be added to your references and added to the top of your DWStorer.cs file.
DocuWare
You may have to go to the link above to download their tool if you do not have it in your project somewhere.

Acumatica - error when customizing "Marketing Campaign" screen

I am having the following error when adding any custom field or overriding any attribute on existing fields on Marketing Campaign screen:
\App_RuntimeCode\PX_Objects_CR_CRCampaign_extensions.cs(1): error CS0246: The type or namespace name 'AP' could not be found (are you missing a using directive or an assembly reference?)
Any idea on where to track this error?
This likely occurred because of using static directive or nested namespace.
For example, having AP.xyz nested in PX.Objects.AP produces no compiler error:
When AP.xyz is nested in another namespace it's not found:
The issue with using static directive is a bit different but results in the same error. This can occur because runtime code uses IIS for compilation and IIS compiler is not the latest dot net compiler. So using static directive can work when you compile a dynamic library extension in visual studio but can fail when it's compiled by IIS as part of a runtime customization.
The easy fix is to edit the files to either:
Fully qualify the identifiers by changing AP.xyz to PX.Objects.AP.xyz
Sometimes all that is required is to remove AP. and add using PX.Objects.AP at the top of the file if it's not there. When there's a conflict between 2 types with the same name in different namespace you must use method #1.

CS0246: The type or namespace name 'MySql' could not be found

how i can fix this problem??
help me
Compiler Error Message: CS0246: The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference?)
Line 1: using MySql.Data.MySqlClient;
Apologies if this is not the case but working on the assumption that you're developing in a version of Visual Studio, check the project references.
If MySql.Data exists in the references but has the warning (yellow triangle) indicator next to it then you may need to re-reference the .dll from its location in your filesystem.
Alternatively, you can grab this from the Nuget package manager if it is not available locally.
Despite the full namespace qualification, the library must be correctly referenced for the object namespace to be recognised in the IDE.
Let us know what IDE you're using if not VS.

Type or namespace name 'Data' does not exist in the namespace 'System'

I'm trying to build my first ASP.NET Web Forms project but I'm facing some serious problem.
I created two project files in my project named: BLL and DAL.
I created classes named class.cs and class1.cs in both the above files respectively. When I add using System.Data; in any of the .cs files, it displays the following errors:
1: Error CS0234 The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?) DAL..NET Platform 5.4
2. Error CS0234 The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?) BLL..NET Platform 5.4
I tried adding assembly references by right click on references -> Add reference -> Checking System.Data and rebuilding it again but it didn't help me.
When I hover mouse over using System.Data; it displays the following thing:
First when you hover your "System.Data" it shows a message, which is pretty much straight forward to understand that you haven't used any classes of System.Data. When you implement those classes, this message will disappear.
Second, You got an error -
Error CS0234 The type or namespace name 'Data' does not exist in
the namespace 'System' (are you missing an assembly reference?)
DAL..NET Platform 5.4
So basically you have to have an assembly refernce of System.Data into your project.
Go to References and check whether System.Data Assembly exist or not. If not then install it.
Hope this will help you.
You are simply missing the "System.Data" reference.
In Solutions Explorer window right click on the 'Reference' entry -> Press Add Reference -> click on Assemblies > Search for 'System.Data' -> press the check box ( I always forget this step.) -> press OK.
your namespace and class name is same,
rename your class name.

Categories