In my current UWP application, I am receiving 19062 errors, all of which begin with "The .winmd file (filename) contains type (type name) outside its root namespace (namespace name)." Examples of the full error code are shown below.
I have attempted the following to resolve the error:
Restarting Visual Studio
Rebuilding the Solution
Reinstalling the most recent version of the Windows SDK
Restarting my computer
The project was building fine a few days ago. Since then, I have not done anything to my computer which would result in such an issue with my solution.
Here are the error code examples:
"The .winmd file 'Windows.Foundation.UniversalApiContract.winmd' contains type 'Windows.ApplicationModel.Search.ISearchQueryLinguisticDetails' outside its root namespace 'Windows.Foundation.UniversalApiContract'. Make sure that all public types appear under a common root namespace that matches the output file name."
"The .winmd file 'Windows.Foundation.UniversalApiContract.winmd' contains type 'Windows.Graphics.Display.DisplayInformation'. The use of the Windows namespace is reserved."
"The .winmd file 'Windows.Foundation.UniversalApiContract.winmd' contains type 'Windows.UI.Xaml.Automation.IValuePatternIdentifiers' outside its root namespace 'Windows.Foundation.UniversalApiContract'. Make sure that all public types appear under a common root namespace that matches the output file name."
I am relatively new to UWP, and am failing to interpret the error. Any help would be much appreciated. Thanks in advance for any help.
Jordan.
The project needed to be cleaned to avoid these errors. OP confirmed in comments that it was a cause.
Related
What I am trying to achieve is to scan my loacal network for connected devices. I learned that I need to construct a selector and pass it to function
DeviceInformation.FindAllAsync()
for example. The problem is, however, all of these require the System.Devices namespace e.g.
System.Devices.InterfaceClassGuid:="{2eef81be-33fa-4800-9670-1cd474972c3f}"
and I get such an error: "Error CS0234 The type or namespace name 'Devices' does not exist in the namespace 'System' (are you missing an assembly reference?)".
I suspect this is because I'm missing the library somehow. I tried
using System.Devices
but again namespace does not exist in the namespace. I also tried adding it in the Reference Manager but there is no such library either.
I couldn't find the library online.
Also I am not exactly sure how to construct AQS strings.
DeviceInformationCollection collection = await DeviceInformation.FindAllAsync(DeviceClass.ImageScanner);
This is ok but showing local devices only.
var selector = System.Device.Aep.ProtocolId:= "{37aba761-2124-454c-8d82-c42962c2de2b}";
This gives errors, one with namespace and more syntax-bound.
I expect passing a selector to the function but I'm missing the namespace System.Devices and AQS strings don't work.
It seems like this is not a namespace. They are windows properties, please check windows properties.
System.Devices is not a namespace. They are Device information properties. if your want enumerate device, you need use DeviceWatcher to capture device that match condition.
DeviceWatcher deviceWatcher = DeviceInformation.CreateWatcher(
"", // AQS Filter string
null, // requested properties
deviceInfoKind);
And this is official code sample that you could refer.
"DeviceWatcher" sounds great — it says:
"Build the sample
Start Visual Studio and select File > Open > Project/Solution.
Go to the directory to which you unzipped the sample. Then go to the subdirectory containing the sample in the language you desire - either C++, C#, or JavaScript. Double-click the Visual Studio Solution (.sln) file.
Select the appropriate target: x86, x64, ARM. Press Ctrl+Shift+B, or select Build > Build Solution.
Ah, but then the catch comes:
"The type or namespace 'System' could not be found."
It supplies "using System;" in all the header lines, it but demands "using Windows;" and rejects all the others.
Go figure —
I am working on an ASP.NET website and as part of the website I created a file called Global.cs which is used to hold all my helper classes. However, unfortunately, I am constantly getting errors saying there has been a problem while compiling this file. All the classes inside the file are included in single namespace - "Global".
When using it 'inline' eg. Global.SomeStaticClass.Method() :
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Global' does not exist in the current context
When using "using Global;" directive:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Global' could not be found (are you missing a using directive or an assembly reference?)
As suggested in many posts, I tried including the class in App_Code folder of my project and the namespace, "Global", is detected by the Visual Studio (no errors when adding "using Global;" directive, or when using it inline "Global.Class.Method()". However, it still fails whenever I try to access the page in the browser.
I could not find a simple solution to my problem and decided that the easiest and the most time efficient solution will be to convert my Website project to a Web Application project. You can read how to convert your Website to a Web Application at: https://blogs.msdn.microsoft.com/webdev/2009/10/29/converting-a-web-site-project-to-a-web-application-project/
With the project converted to a Web App I was able to attach my class files after compiling them to a DLL library, as it did not accept any uncompiled files inside App_Code folder by throwing an exception.
The directory '/website/App_Code/' is not allowed because the application is precompiled.
If you encounter the same issue, you can learn how to compile C# files using Developer Command Prompt here: https://msdn.microsoft.com/en-us/library/78f4aasd.aspx
I'm attempting to use the following command line command to compile an assembly of the code from my project:
C:/"Program Files"/Unity/Editor/Data/Mono/bin/gmcs
-target:library -out:C:/Users/Austin/Desktop/PixelExpanse.dll
-recurse:C:/Users/Austin/Desktop/Projects/Repos/trunk/PixelExpanse/SpaceColonyRefactor/Assets/Source/*.cs
-d:RUNTIME -r:C:/"Program Files"/Unity/Editor/Data/Managed/UnityEngine.dll
As you can see, I am, I believe, correctly referencing the UnityEngine.dll.
The code that would be compiled contains references to UnityEngine.UI and UnityEngine.EventSystems. But when I run the above command, I get the following compile error:
error CS0234: The type or namespace name 'EventSystems' does not exist in the namespace 'UnityEngine'. Are you missing an assembly reference?
From what I have been able to find through googling, it SEEMS like an error people were getting when using a pre-4.6 assembly, because thats when EventSystems and UI were both introduced. But I don't know how I could be missing that in the dll I'm referencing as Unity 5 is the only version that has ever touched this computer.
As a side note, I have posted this question to Unity Answers and have yet to receive a response. I expect it's because assembly compilation is beyond the scope of what most users there choose to undertake. Hence my asking it here.
The namespace UnityEngine.EventSystems actually appears in UnityEngine.UI.dll and not UnityEngine.dll so it seems you need to reference the former too when compiling manually from the command-line. Unity projects have this by default (see below).
This is verified by opening up the assembly in your reflector tool of choice, here I am using JetBrains dotPeek:
This is how my test project appears with default Unity references. Note that by default a reference to UnityEngine.UI already appears in the Unity-created project:
When I built my Windnows desktop app via Unity, the above dlls appeared in:
<drive>:<projectOutFolder>\<projectName>_Data\Managed
You can try:
right click on "project panel", and after "Reimport All".
It's can be happen due to switch between platforms, e.g. IOS, or Desktop.. thus, folrders are deleted by became unecessary..
Solve for me: Unity 5.2, Win 7, 32bits;
Good luck!
I checked the UnityEngine.dll and the Eventsystems/UI namespace is not included. Despite, there is a dll in Unity5\Editor\Data\UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll which includes these namespaces.
For mac, it's /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll.
I have a C# app originally written in Windows that I'm now running in Linux on MonoDevelop. It works fine but now I need to recognise symbolic links. I found this answer but when I add:
using Mono.Unix;
I get the error "The type or namespace name 'Unix' does not exist in the namespace 'Mono'. Are you missing an assembly reference (CS0234)?"
You need to do what the error message says. Unintuitively, Mono.Unix lives in Mono.Posix.dll, so you need to add that as reference.
I've downloaded the IKVM sources (http://www.ikvm.net/) from http://sourceforge.net/cvs/?group_id=69637
Now I'm trying to get it to build in Visual Studio 2008 and am stuck. Does anyone know of documentation of how to build the thing, or could even give me pointers?
I've tried opening the ikvm8.sln, which opens all the projects, but trying to build the solution leads to a bunch of "type or namespace could not be found" errors.
As you can probably guess I'm no Visual Studio expert, but rather am used to working with Java in Eclipse.
So again, I'm looking for either: step-by-step instructions or a link to documentation on how to build IKVM in Visual Studio.
Let me know if you need any more info. Thanks for any help!
Edit: I've also tried a manual "MsBuild.exe IKVM8.sln", but also get a bunch of:
JniInterface.cs(30,12): error CS0234: The type or namespace name 'Internal' does not exist in the namespace 'IKVM' (a
re you missing an assembly reference?)
JniInterface.cs(175,38): error CS0246: The type or namespace name 'ClassLoaderWrapper' could not be found (are you mi
ssing a using directive or an assembly reference?)
JniInterface.cs(175,13): error CS0246: The type or namespace name 'ClassLoaderWrapper' could not be found (are you mi
ssing a using directive or an assembly reference?)
Edit #2: I noticed a "ikvm.build" file so I downloaded and ran nant on the folder, which got me a step further. A few things start to build successfully, unfortunately I now get the following error:
ikvm-native-win32:
[mkdir] Creating directory 'C:\Documents and Settings\...\My Documents\ikvm\ikvm\native\Release'.
[cl] Compiling 2 files to 'C:\Documents and Settings\...\My Documents\ikvm\ikvm\native\Release'.
BUILD FAILED
C:\Documents and Settings\...\My Documents\ikvm\ikvm\native\native.build(17,10):
'cl' failed to start.
The system cannot find the file specified
Total time: 0.2 seconds.
Edit #3: OK solved that by putting cl.exe in the path, still getting other errors though. Note this is all for building it on the console e.g. with Nant. Is there no way to get it to build in Visual Studio? That would be sad...
Edit #4: Next step was installing GNU classpath 0.95, and now it looks like I need a specific OpenJDK installation... Linux AMD64?!
[exec] javac: file not found: ..\..\openjdk6-b12\control\build\linux-amd64\gensrc\com\sun\accessibility\internal\resources\accessibility.java
[exec] Usage: javac <options> <source files>
[exec] use -help for a list of possible options
Edit #5: Got an answer from the author. See below or at http://weblog.ikvm.net/CommentView.aspx?guid=7e91b51d-6f84-4485-b61f-ea9e068a5fcf Let's see if it works...
Edit #6 As I feared, next problem: "cannot open windows.h", see separate question here.
Final Edit: Found Solution! After getting the Platform SDK folders in the Lib and Path environment variables, the solution I described below worked for me.
I don't know that this would do it for you but can you try building from the command line?
msbuild ________
I think that's how I built the application due to the same issues.
OK just got the following reply from the author: http://weblog.ikvm.net/CommentView.aspx?guid=7e91b51d-6f84-4485-b61f-ea9e068a5fcf
If you want to build from cvs, you're on your own. However, you can more easily build from source if you use an official release.
If you download ikvm-0.36.0.11.zip, classpath-0.95-stripped.zip and openjdk-b13-stripped.zip from SourceForge (the last two are under the ikvm 0.36.0.5 release) you have all the sources that are needed.
Now you'll have to open a Visual Studio 2008 Command Prompt (i.e. one that has cl.exe and peverify in the path).
Then in the ikvm root directory, do a "nant clean" followed by "nant". That should build the whole project. After you done that, you should be able to build in Visual Studio (debug target only), but you may need to repair the assembly references in the projects (unless you have ikvm installed in c:\ikvm).
Regards,
Jeroen
Edit: After making sure the Platform SDK folders were in the Path and Lib environment variables, this worked for me. Thanks, Jeroen!
This is how I built IKVM 8.1.5717.0 from source. Visual Studio is not required.
Create a folder:
c:\ikvm\
Add the above folder to PATH (e.g. set PATH=%PATH%;c:\ikvm and leave command prompt open for later).
Download:
ikvmsrc-8.1.5717.0.zip (http://www.frijters.net/ikvmsrc-8.1.5717.0.zip)
Unzip and place "ikvm-8.1.5717.0" folder in c:\ikvm\
Download:
openjdk-8u45-b14-stripped.zip (http://www.frijters.net/openjdk-8u45-b14-stripped.zip)
Unzip and place "openjdk-8u45-b14" folder in c:\ikvm\
Download:
Java 8 SDK (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
Install and make sure location is added to path
Download:
NAnt 0.92 (https://sourceforge.net/projects/nant/files/nant/0.92/nant-0.92-bin.zip/download)
Unzip and place "nant-0.92" folder in c:\ikvm\
ICSharpCode.SharpZipLib.dll (http://www.icsharpcode.net/opensource/sharpziplib/Download.aspx)
Place "ICSharpCode.SharpZipLib.dll" in C:\ikvm\ikvm-8.1.5717.0\bin\
Open the following file in a text editor and change the version number:
C:\ikvm\ikvm-8.1.5717.0\CommonAssemblyInfo.cs.in
Using command prompt from earlier, cd to:
C:\ikvm\ikvm-8.1.5717.0\ikvm\
Run:
..\nant-0.92\bin\NAnt.exe
If successful all the binaries will be in:
C:\ikvm\ikvm-8.1.5717.0\bin