Reputation: 1001
I have a website in ASP.NET and I've added the reference UnityEngine.dll because I need to use this library. In my homepage I have this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using UnityEngine;
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Network.InitializeServer(2, 8008, true); //Provided by the library UnityEngine
}
}
When I run the website and press the button the web shows me this error:
The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
System.Security.SecurityException: ECall methods must be packaged into a system module.
I searched information but I can not find the solution to this problem.
Upvotes: 1
Views: 1672
Reputation: 301
Sorry for reviving an old thread. Since I kept repeating the same mistake myself and forgetting I thought I would drop a note here for myself and those that are interested.
The UnityEngine.dll has a lot of functions that lead to nowhere that you will find. This is because the supplied CLR VM implements them. This is done via the attributes on the functions that mark them as such. MS themselves do this for their more nested functions in base DLLs.
For example;
// Unity Network Class
class Network ...
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
void InitializeServer( ...
}
So basically you can never import this into Visual Studio directly. This doesnt stop you creating some merge via Unity development environment to talk to your Visual Studio App?
If you do something with the Unity dll I recommend RedGates .Net Reflector
References: Vlads Happy Place
Upvotes: 1