I'm using mono on macOS and trying to compile this C# code: https://gist.github.com/bneg/bf8c05664324e3efeb1fb05902152a20
with following command:
mcs Program.cs
It produces following error:
Program.cs(4,14): error CS0234: The type or namespace name `Management' does not exist in the namespace `System'. Are you missing an assembly reference?
Program.cs(5,14): error CS0234: The type or namespace name `Management' does not exist in the namespace `System'. Are you missing an assembly reference?
I also tried it with following command:
mcs -pkg:dotnet Program.cs
I got this error:
Program.cs(17,25): error CS0234: The type or namespace name `Automation' does not exist in the namespace `System.Management'. Are you missing an assembly reference?
Program.cs(18,25): error CS0234: The type or namespace name `Automation' does not exist in the namespace `System.Management'. Are you missing an assembly reference?
What changes should be made in order to compile it?
I'm not sure if you can run powershell like that via mono on mac os.
As a minimum you would need to reference something like this:
https://www.nuget.org/packages/System.Management.Automation
But this is not guaranteed to be working if you do not have powershell installed. And since powershell on linux (sic!) can only run on .net core, chances are, you cannot get what you are trying to accomplish.
Related
I just pushed a test project for travis to build, but it fails. Error:
ConsoleHelpersTests.cs(2,17): error CS0234: The type or namespace name
VisualStudio' does not exist in the namespaceMicrosoft'. Are you
missing an assembly reference?
my .travis.yml file:
language: csharp
solution: TravisDotNet.sln
Am I missing something?
I tried to compile a example from Mono website:
http://docs.go-mono.com/?link=T%3aGtkSourceView.SourceView
I tried to use this command:
mcs -pkg:gtk-sharp-2.0,gtksourceview2-sharp task3.cs
I've got a errors:
task3.cs(17,3): error CS0246: The type or namespace name SourceLanguagesManager' could not be found. Are you missing an assembly reference?
task3.cs(20,29): error CS0841: A local variablemanager' cannot be used before it is declared
task3.cs(24,10): error CS1061: Type GtkSourceView.SourceBuffer' does not contain a definition forHighlight' and no extension method Highlight' of typeGtkSourceView.SourceBuffer' could be found. Are you missing an assembly reference?
How to compile this example on Ubuntu 14.04 LTS?
I am trying to run a C# program in linux using mono gmcs compiler. I need to include a namespace Microsoft.Boogie. I have the source code for the C# package which defines Boogie namespace. But when I try to use
using Microsoft.Boogie;
the compiler (gmcs) complains that
boogieTrace.cs(2,17): error CS0234: The type or namespace name `Boogie' does not
exist in the namespace `Microsoft'. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
Does anyone know how to include custom namespaces in a C# program?
I'm running MonoDevelop with MonoTouch and am trying to target a device (i.e. Debug|iPhone) when building the code. However when I do that the compiler throws a bunch of errors referring to missing assemblies.
If I build to target a simulator these errors don't show up, I know I have the assemblies included and even the IDE 'sees' the assemblies and autocompletes namespaces in these assemblies as I type them out.
Any ideas what could be causing it? I've already tried fresh rebuilds...
I updated from a trial version of MonoTouch if that makes any difference.
Here are some of the errors (they're all this sort of error):
/Users/ahmedhakeem/Documents/Projects/iOS/MyCode/Engine/Util/UI/MenuObj.cs(31,31): Error CS0234: The type or namespace name `Audio' does not exist in the namespace `Microsoft.Xna.Framework'. Are you missing an assembly reference? (CS0234) (Engine-MonoTouch)
/Users/ahmedhakeem/Documents/Projects/iOS/MyCode/Engine/Util/UI/MenuObj.cs(31,31): Error CS0234: The type or namespace name `Media' does not exist in the namespace `Microsoft.Xna.Framework'. Are you missing an assembly reference? (CS0234) (Engine-MonoTouch)
/Users/ahmedhakeem/Documents/Projects/iOS/MyCode/Engine/JabJect.cs(40,40): Error CS0246: The type or namespace name `ContentManager' could not be found. Are you missing a using directive or an assembly reference? (CS0246) (Engine-MonoTouch)
/Users/ahmedhakeem/Documents/Projects/iOS/MyCode/Engine/Media/Sprite.cs(31,31): Error CS0234: The type or namespace name `Audio' does not exist in the namespace `Microsoft.Xna.Framework'. Are you missing an assembly reference? (CS0234) (Engine-MonoTouch)
/Users/ahmedhakeem/Documents/Projects/iOS/MyCode/Engine/Scene/GameScene.cs(42,42): Error CS0246: The type or namespace name `ContentManager' could not be found. Are you missing a using directive or an assembly reference? (CS0246) (Engine-MonoTouch)
If you're using MT 4.x then there were some races when the assemblies were compiled into native code. However the errors from your description looks to be from compiling managed code (and that's not done in parallel so there should not be any race condition affecting that part of the build).
That would make it (sometimes) skip an assembly at link time, leading to (hard to reproduce) build errors. This will be fixed in the next release of MonoTouch.
This never happens on the simulator since there's no AOT (compile to native) occurring in that case (i.e. the JIT is used).
I have created a C# console application that contains the namespaces System and System.Data
Additionally, I have added Microsoft.SqlServer.Smo.
When I try to compile from command prompt it shows the error as:
SqlSmoDiscovery.cs(3,27): error
CS0234: The type or namespace name
'Management'
does not exist in the namespace 'Microsoft.SqlServer' (are
you missing
an assembly reference?) SqlSmoDiscovery.cs(4,27): error
CS0234: The type or namespace name
'Management'
does not exist in the namespace 'Microsoft.SqlServer' (are
you missing
an assembly reference?)
But it compiles from Visual Studio.
I am compiling from command prompt to have output as pure C# dll.
My Project in g:
then i navigate to G:\SqlDisc:> csc /target:library /r Micrsoft.SqlServer.Smo.Dll
SqlSmoDiscovery.cs but it shows the erroe as
error CS0006: Metadata file 'Microsoft.SqlServer.Smo.dll' could not be found
Use the /r flag to reference additional assemblies from the command line.
csc /target:library /r:OtherAssembly.dll Foo.cs
For more info, see the reference for the csc.exe tool.