C# help with a namespace issue

Started by col, June 15, 2018, 13:29:01

Previous topic - Next topic

col

Hiya all,

I'm creating a C# library in a namespace structure set up as

namespace NamespaceA.NamespaceB
{
public interface IInterface
{
[... some declared methods ...]
}

public class SomeClassBase : IInterface
{
public [... all declared methods of IIinterface are implmeneted...]
}

namespace NamespaceC
{
public class SomeClass : SomeClassBase
{
public [... some more public methods ...]
}
}
}


In an application that references the library I'm using ( I know I can use 'using' declaratives but this example is for clarity )

NamespaceA.NamespaceB.IInterface data = new NamespaceA.NamespaceB.NamespaceC.SomeClass();

but I'm getting 'The type or namespace name 'IInterface' does not exist in the namespace 'NamespaceB'.
There are other classes in the NamespaceB namespace in other files.
Using VStudio 2017Pro, the library and application are building against .Net 4.6.1, both are building for x64, the application has a 'confirmed' reference to the library.

I'm a little lost as too why the error is occuring. I've browsed through SO for over an hour to no avail, so I thought I'd ask here :)

https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

Steve Elliott

Quote
I'm a little lost

So am I looking at that code lol.  Your recent Blitz3D code in another thread was far more readable  :)
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
Linux Mint 8Gb Celeron Intel UHD Graphics 600
macOS Sonoma 32Gb Apple M2 Max
Spectrum Next 2Mb

Derron

Instead of browsing "over SO" you might consider asking for help there? Think sooner or later you will get a concise answer.


bye
Ron

col

#3
QuoteSo am I looking at that code lol.  Your recent Blitz3D code in another thread was far more readable  :)
Blitz3D is much better of course :)

The issue is this system that I'm working on at work has to expand in the future to be used by other clients. There are many common datas used by all clients and some that won't be. Using interfaces is a good way to 'force' any newer client code to include the 'base' client code instead of me forgetting that the base code exists and rewriting it all in the future.



This error was a red herring - thanks MS  :P

The real issue was the whole build system was screwed up by a typo in a post-build event. I was copying files that are built from different projects in the same solution into a 'release' folder. However the typo: '$(TargetFile)' instead of '$(TargetPath)' in the post-build copy command, didn't cause any errors per-se but caused everything from the 'release' folder to be copied into the local project/x64/release folder so who knows what version the build system was trying to use when it came to building this dll  :)) The build system was moving the wrong files to the wrong places without warning or error.

I corrected the typo and all is good :)
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

col

QuoteInstead of browsing "over SO" you might consider asking for help there? Think sooner or later you will get a concise answer.
To be honest most of the issues I ever have - someone has had the same and resolved it before me, to the point that if it's not on SO then I have a 'stand-alone' problem... and sure enough the error was as above :)
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

Goodlookinguy

#5
I'm extremely familiar with C# and have never had this issue. In fact, trying your code, it all worked. So it's something else you're doing, but it isn't related to your example code.

Edit:
Make sure you have your references all setup correctly. Because, based on that error, IInterface isn't available to whatever dll or exe you're trying to access it on.
I'm insane and not in a funny or good way! nrgs.org