Ooops
October 19, 2021, 08:44:49

Author Topic: C# help with a namespace issue  (Read 2633 times)

Offline col

  • Hero Member
  • *****
  • Posts: 598
C# help with a namespace issue
« on: June 15, 2018, 13:29:01 »
Hiya all,

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

Code: [Select]
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 )

Code: [Select]
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 :)

« Last Edit: June 15, 2018, 13:30:36 by col »

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 3235
  • elgol
Re: C# help with a namespace issue
« Reply #1 on: June 15, 2018, 14:47:52 »
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  :)
Windows 10 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
MacOS Big Sur 64-bit, 8Gb RAM, Intel i5 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB
Linux Mint 19.3 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
Raspberry pi 3, pi 4, pi 400, BBC B, C64, ZX Spectrum

Offline Derron

  • Hero Member
  • *****
  • Posts: 3664
Re: C# help with a namespace issue
« Reply #2 on: June 15, 2018, 14:50:45 »
Instead of browsing "over SO" you might consider asking for help there? Think sooner or later you will get a concise answer.


bye
Ron

Offline col

  • Hero Member
  • *****
  • Posts: 598
Re: C# help with a namespace issue
« Reply #3 on: June 15, 2018, 15:03:10 »
Quote
So 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 :)
« Last Edit: June 15, 2018, 15:06:35 by col »

Offline col

  • Hero Member
  • *****
  • Posts: 598
Re: C# help with a namespace issue
« Reply #4 on: June 15, 2018, 15:05:25 »
Quote
Instead 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 :)

Offline Goodlookinguy

  • Full Member
  • ***
  • Posts: 146
    • How to be Unprofessional: A Blitz Research Ltd Story
Re: C# help with a namespace issue
« Reply #5 on: June 17, 2018, 05:01:16 »
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.
« Last Edit: June 17, 2018, 05:10:48 by Goodlookinguy »
I'm insane and not in a funny or good way! nrgs.org

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal