-
February 12th, 2003, 03:51 AM
#1
opengl and managed code
I want to use some of the .net classes in a program that uses opengl. But if I enable managed code (#using <mscorlib.dll> and /clr) I get an error regarding an opengl object. The exact error is a runtime error and is:
----------
An unhandled exception of type 'System.TypeLoadException' occurred in Go.exe
Additional information: Could not load type GLUquadric from assembly Go, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
----------
The program runs fine if I do not use the /clr option. I am new to the whole .net thing so maybe I am doing something wrong.
Chris
-
March 3rd, 2006, 01:13 PM
#2
Re: opengl and managed code
Hi. I have the same problem of you. In My solution I have a project that uses opengl. I have other project that is mixed: an managed wrapper that wrap unmanaged code. This managed wrapper exports some structs like the code below:
Code:
public __gc struct Pacote_artilharia
{
public:
String* nome; // Nome.
String* descricao; // Descrição.
String* letalidade; // Letalidade.
String* unidade; // Unidade de Combate.
int fixo; // Pode ser movido.
double latitude; // Latitude (rad).
double longitude; // Longitude (rad).
double altitude; // Altitude (m).
int posicionamento; // Posicionamento PolÃ*tico (Amigo,Inimigo).
int operacao; // Operação (Ativo,Inativo).
double tempoResposta; // Tempo de Resposta (s).
double alcance; // Alcance efetivo (m).
int id_; // Chave.
int Ativo; // O objeto atual está ativo?
};
When the application is running i get the run time error: System. Typeloadexception
-
March 4th, 2006, 02:13 AM
#3
Re: opengl and managed code
-
March 6th, 2006, 12:04 PM
#4
Re: opengl and managed code
Thank you for the links Alex. But these don’t work for me.
Let me explain my problem better.
I have a solution that has basically an interface project (main project) written in C# (called PDA), that uses other project written as well in C# that access OpenGL (this is called FrameworkGis), and uses another project written in C++ Managed extensions that has the basic logic process, this last one is called PDAManager. PDAManager is written in C++ with an wrapper written in C++ /CLI, who exports some structures for PDA (the first one).
Summary:
PDA (C#)-> FrameworkGis (C# and OpenGL)
PDA (C#)-> PDAManager (C++ /CLI)
In PDAManager (C++ /CLI), I have this code which exports these structures.
Code:
// PDAManager.h
//....
#pragma managed
using namespace System;
using namespace System::Collections;
namespace IEAv_PDACPP {
public __gc struct Pacote_radar
{
public public:
String* nome; // Nome
String* descricao; // Descrição
int fixo; // Pode ser movido.
double latitude; // Latitude (Graus).
double longitude; // Longitude (Graus).
double altitude; // Altitude (m).
int posicionamento; // Posicionamento PolÃ*tico (Amigo,Inimigo).
int operacao; // Operação (Ativo,Inativo).
double azimuteInicial; // Azimute Inicial (rad).
double azimuteFinal; // Azimute Final (rad).
double feixeInicial; // Feixe Inicial (rad).
//...
};
// ---------------------------------------------------------------------------------
public __gc struct Pacote_incursor
{
public:
String* nome;
String* descricao;
int posicionamento; // Posicionamento PolÃ*tico (Amigo,Inimigo).
int fixo; // Pode ser movido.
int operacao; // Operação (Ativo,Inativo).
double velocidade; // Velocidade (knot).
double tempoAutonomia; // Tempo de Autonomia.
double altimetria; // ALTURA ou ALTITUDE .
//...
};
//....
In PDA, I use this structures, see the code.
Code:
// PDA
using IEAv_PDACPP;
class Radar: PDAObject{
// estrutura de dados, que vem da camada C++. É usada para trocar dados entre as camadas.
private Pacote_radar _radarDados;
#region Dados e propriedade Do Radar
//private string descricao;
private int posicionamento; //Posicionamento PolÃ*tico (Amigo,Inimigo).
private int operacao; //Operaçãoo (Ativo,Inativo).
private double azimuteInicial; //Azimute Inicial (rad).
public Radar(Ponto point, double Red, double Green, double Blue, string TexturaArquivo, Pacote_radar p_umRadar ):base(point, Red, Green, Blue, TexturaArquivo) {
pdaManager.CriarRadar( p_umRadar );
_radarDados = p_umRadar;
definirAsPropriedadesComAEstrutura();
SPosicaoGeografica posgeo = new SPosicaoGeografica();
posgeo.Latitude = _radarDados.latitude;
posgeo.Longitude = _radarDados.longitude;
pdaManager.DefinirAltitudeParaPosicaoGeografica( posgeo );
_radarDados.altitude = posgeo.Altitude;
this.altitude = posgeo.Altitude;
//...
}
/**
* Pre Condition: Must have _radarDados defined
*/
private void definirAsPropriedadesComAEstrutura(){
//nome = RadarDados.;
descricao = _radarDados.descricao;
//set {
//descricao = _radarDados.descricao;
nome = _radarDados.nome;
latitude = _radarDados.latitude;
longitude = _radarDados.longitude;
altitude = _radarDados.altitude;
fixo = _radarDados.fixo;
posicionamento = _radarDados.posicionamento; //Posicionamento PolÃ*tico (Amigo,Inimigo).
operacao = _radarDados.operacao; //Operaçãoo (Ativo,Inativo).
azimuteInicial = _radarDados.azimuteInicial; //Azimute Inicial (rad).
//...
}
private void definirAEstruturaComAGridDoRadar(){
_radarDados.descricao = descricao;
_radarDados.nome = nome;
_radarDados.fixo = fixo;
_radarDados.latitude = latitude;
_radarDados.longitude = longitude; //Longitude (Graus).
_radarDados.altitude = altitude; //Altitude (m).
_radarDados.posicionamento = posicionamento; //Posicionamento PolÃ*tico (Amigo,Inimigo).
_radarDados.operacao = operacao; //Operaçãoo (Ativo,Inativo).
_radarDados.azimuteInicial = azimuteInicial; //Azimute Inicial (rad).
//pdaManager.AlterarRadar( _radarDados );
//...
}
See that Pacote_radar is defined in PDAManager (C++/CLI) and used in PDA (C#).
The problem is that I got this runtime error:
An unhandled exception of type 'System.TypeLoadException' occurred in frameworkgis.dll .
Additional information: Could not load type IEAv_PDACPP.Pacote_radar from assembly PDAManager, Version=1.0.2242.29545, Culture=neutral, PublicKeyToken=null.
I have tried the solutions quoted above.
Thanks.
-
March 7th, 2006, 01:50 PM
#5
Re: opengl and managed code
It was missing PDAManager.dll in a folder. After copy it, the problem disappear.
Now everything is fine.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|