Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4099470
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:26:16+00:00 2026-05-20T20:26:16+00:00

I’ve been looking and looking all over the net about how to load an

  • 0

I’ve been looking and looking all over the net about how to load an assembly in Unity3D, and I’m having a real hard time. I’m sorry if this post will be long, but I’ll be putting everything I’ve learned and how far I’ve gotten since this is my first time working in .net and dlls.

I have a native dll, it has a whole bunch of extern “C” so I can load everything at runtime. This works in unity if I use the [DLLImport] attribute and such. However, it’s cumbersome, and not really reusable code. It would become even more cumbersome later when I will have to abstract my system between more than 1 native library.

So I figured I’d do a C+++/CLI wrapper and then load it in Unity3d like any other dll and just link the namespace: “using MyWrapper;”

I created the simplest C++/CLI lib I could think of. all my lib does is have a class (Class1) and it has a function int getnum() {return 5;}. I’m using VC++ 2010 express, and I’m building with V90, and modified the vcxproj file to target 2.0. I know unity only supports 2.0. I’m building in /clr in order to be able to have native and .net code.

It completely crashes unity3d.
This is my Error log
at GameManager.Awake () [0x0001d] in Manager\GameManager.cs:116
at GameManager.Awake () [0x00000] in Manager\GameManager.cs:107
at (wrapper runtime-invoke) GUIRadioButton.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>
Receiving unhandled NULL exception

if I build it in /clr:safe instead it works fine. /clr:pure also doesn’t work.

So I decided to do an external c# command line project to test everything. I load my lib, and compile in 2.0 and /clr (mixed mode) works without a problem.

I’m using Unity 2.6 Pro.

It’s possibly what I’m looking to do is impossible, I don’t know.. I mean I figured that was what .NET was all about. I just want to have a system which can be reused in other projects (C++).

Thanks for any insight.

Here’s my test c++/cli project.

#pragma once

using namespace System;

namespace CLRTest {

    public ref class Class1
    {
        // TODO: Add your methods for this class here.
    public:

        Class1(){}

        int getnum (){return 5;}
    };
}

When I create a C# command line project like this. it works.

using System;
using System.Collections.Generic;
using System.Text;
using CLRTest;

namespace CLRTestLoad
{
    class Program
    {
        static void Main(string[] args)
        {
            Class1 c = new Class1();

            Console.WriteLine ("num is = " + c.getnum());
        }
    }
}

Executing this line in Unity3d crashes the whole editor. (Yes I did put in the using statement)

Class1 c = new Class1();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:26:18+00:00Added an answer on May 20, 2026 at 8:26 pm

    AFAIK, C++/CLI assemblies are not working with Unity, as Unity is relying on Mono that doesn’t support mixed assemblies. The only workaround is to call functions from a dll with classic p/invoke

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm looking for suggestions for debugging... If you view this site in Firefox or
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.