Managed Code in Unmanaged C++

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
LuxuriousMeat





Posts: 824
Joined: Thu Nov 03, 2005 6:43 pm
Location: zzzzzzzzzzzzzzzz
Contact:

Managed Code in Unmanaged C++

Post by LuxuriousMeat »

I followed Microsofts instructions, but when I compile my un-managed C++ project and it imports my type library it find a **** load of errors and it fails to build. Has anyone ever done this before that can help me?
The error's are like this:

Code: Select all

IO.tlb stray '\255' in program
Instructions for it can be found here:
http://support.microsoft.com/kb/828736

Here's my code I'm compiling into a type library:

Code: Select all

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace IO
{
    public class ReaderWriter : IReaderWriter
    {
        public int GetInt32(string path, int offset)
        {
            BinaryReader br = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite));
            if ((br.BaseStream.Length - 4) >= offset)
            {
                br.BaseStream.Position = offset;
                int ret = br.ReadInt32();
                br.Close();

                return ret;
            }
            return -1;
        }
    };

    public interface IReaderWriter
    {
        int GetInt32(string path, int offset);
    };
}
Image
Evan





Posts: 105
Joined: Fri Oct 26, 2007 1:26 pm
Location: Indiana

Post by Evan »

Your trying to compile that with C++?
Give me some more info on what your doing and I might be able to help.
Or get on AIM.
User avatar
LuxuriousMeat





Posts: 824
Joined: Thu Nov 03, 2005 6:43 pm
Location: zzzzzzzzzzzzzzzz
Contact:

Post by LuxuriousMeat »

Look at the link, I did exactly that. I compiled it into a .dll in C# and used the Visual Studio Command prompt to convert it into a .tlb (type library). And I did a import statement in my unmanaged C++ project like this:

Code: Select all

#import "IO.tlb" raw_interfaces_only
Image
User avatar
xzodia




Translator Connoisseur Coagulator

Posts: 1981
Joined: Sun May 15, 2005 10:31 am
Location: UK
Contact:

Post by xzodia »

im fairly sure its impossible to import managed code into unmanaged code...
Image
Halo 2 Plugins | Lock-on To Just About Anything | My Sites | Snow Hog
Old Plugins you have, upgrade you must...
Always Maintain a High Quality-To-Crap Ratio.
User avatar
LuxuriousMeat





Posts: 824
Joined: Thu Nov 03, 2005 6:43 pm
Location: zzzzzzzzzzzzzzzz
Contact:

Post by LuxuriousMeat »

Look at the link I posted...
Image
User avatar
xzodia




Translator Connoisseur Coagulator

Posts: 1981
Joined: Sun May 15, 2005 10:31 am
Location: UK
Contact:

Post by xzodia »

>_>
<_<
i stand corrected... :P
Image
Halo 2 Plugins | Lock-on To Just About Anything | My Sites | Snow Hog
Old Plugins you have, upgrade you must...
Always Maintain a High Quality-To-Crap Ratio.
User avatar
LuxuriousMeat





Posts: 824
Joined: Thu Nov 03, 2005 6:43 pm
Location: zzzzzzzzzzzzzzzz
Contact:

Post by LuxuriousMeat »

Never mind guys, I fixed it :D.
Image
Post Reply