0

Here's what I did so far:

  1. Went here and downloaded the source code: http://oggsharp.codeplex.com/SourceControl/latest#OggSharp/CsVorbis . It came as "oggsharp-19c0361a8fa8.zip" and in there is OggSharp\CsVorbis which has all the .cs files I want.

  2. Started a new Class Library project in MS VS 2010. Added all the .cs files from that folder (CsVorbis).

  3. Compiled the project. This made a CsVorbisDll.dll file.

  4. Went to another project of mine---a MonoGame DirectX project---and added a reference to that dll.

  5. Added using CsVorbisDll;, and this part works. So it can see the dll. (EDIT: typod it before. It is using CsVorbisDll;)

  6. Tried to use classes from that dll, such as OggDecoder, but this doesn't work! It says "The type or namespace name 'OggDecoder' could not be found"

Apparently my project can see the dll, but cannot see into the dll. I'm not sure why. The OggDecoder class is public. I noticed, however, that the dll was only 4 KB in size, whereas the source code folder was something like 300 KB. Did it not compile correctly?

I set the Configuration to "Release", not "Debug", when I compiled the dll. My MonoGame Project is also in MS VS 2010, uses DirectX, and otherwise runs fine.

EDIT: What I've verified so far: Both projects target ".NET Framework 4" (not the Client Profile). Both projects have platform target "x86".

Can someone help me set up this dll correctly? I really want it to be a dll. There are too many *.cs from the source to just add them all into my MonoGame Project.

EDIT: I found the answer and posted it. Basically, I had to make the project name the same as the namespace of all the .cs files so that the dll filename is the same as the namespace too.

DrZ214
  • 486
  • 5
  • 19
  • 1
    Both projects compiled under the same version of .NET? – Jonesopolis Jun 24 '15 at 20:03
  • 1
    *"Added "using CsVorbisDll.dll;", and this part works."*. You should read about the difference between assembly references and using directives. – Lucas Trzesniewski Jun 24 '15 at 20:04
  • @Jonesy yes, both have "Target framework: .NET Framework 4" set in project properties. – DrZ214 Jun 24 '15 at 20:07
  • @LucasTrzesniewski sorry i typod it before. It's "using CsVorbisDll;" with no .dll at the end. I shoulda chose a better name for the dll file tho. – DrZ214 Jun 24 '15 at 20:07
  • Did you check that projects are on different 32 bit build mode? – farid bekran Jun 24 '15 at 20:32
  • @faridbekran I just checked, the dll was set to "Any CPU", but my MonoGame Project was set to "x86". They are not both set to "x86". I recompiled and re-tested, but still get the same problem. It can't see inside the dll. If it matters, my machine is 64-bit Windows 7. – DrZ214 Jun 24 '15 at 20:41
  • try [this](http://stackoverflow.com/a/23910959/1095390) steps. maybe it worked. specially cleaning solution. deleting bin/obj folders – farid bekran Jun 24 '15 at 20:49
  • @faridbekran I tried some of those, no luck. Right now I'm hunting through the properties tabs, looking for anything that stands out. Could "Start Actions -> Start External Program" have something to do with it? – DrZ214 Jun 24 '15 at 21:04
  • @DrZ214 I don't think so. – farid bekran Jun 24 '15 at 21:25

3 Answers3

0

If you want to dig deep inside dlls you can try .Net Reflector

You can install the free trial it is good for about 60 days. It installs a new menu into visual studio.

MIKE
  • 1,039
  • 7
  • 24
0

Unless you also changed all the namespaces, you're using statement is incorrect. It should be:

using OggSharp;
Richard Szalay
  • 83,269
  • 19
  • 178
  • 237
  • I didnt change anything in the source code of OggSharp or CsVorbis. The namespaces it uses are indeed "OggSharp". However, "using OggSharp;" in my MonoGame Project gives an error. It can't see it. But it can see CsVorbisDll. I don't understand it either. – DrZ214 Jun 24 '15 at 20:15
0

I figured out what was wrong, but still don't like it.

The .cs files I was compiling all have namespace Oggsharp. So on a whim, I made a new Class Library project and named it OggSharp (instead of CsVorbisDll as before). This time it compiled into an 84 KB dll. I referenced it and was able to use all its classes and functions!

My initial suspicion was right, because CsVorbisDll.dll was compiled as a pitifully small 4 KB dll file. So I guess it didn't compile things into it because the namespaces didnt match up with the dll name?

Upon calling the project OggSharp and making OggSharp.dll, it compiled into an 84 KB dll, with all its insides usable.

Not sure I like this convention/rule. I may do some experiments, e.g., manually renaming the dll and seeing what happens.

DrZ214
  • 486
  • 5
  • 19