从C#DLL导出的函数不起作用

时间:2015-06-06 10:49:49

标签: c# c++ dllexport

我必须在C#中从我的DLL导出3个基本方法,因此可以在C ++中访问它:

  • OnPluginStart
  • OnPluginStop
  • PluginUpdate

所以我发现Unmanaged Exports是一个很好的C#库,可以让它变得更容易。

所以我继续使用示例代码进行测试:

 mActionBar = getActionBar();
    // enabling action bar app icon and behaving it as toggle button
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setHomeButtonEnabled(true);

然而,当我编译我的DLL并使用DLL Exporter Viewer时,它没有列出任何导出的函数,并且加载DLL的应用程序也从不运行我的插件。

我在这里做错了什么导致我的功能根本没有被导出?

1 个答案:

答案 0 :(得分:1)

除了您发布的代码无法编译之外,您的代码工作正常。您省略了@Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); tweenManager.update(delta); worldUpdate(delta); /* We have three cameras (foreground + double parallax background) */ moveForegroundCamera(player.getPosition().x, player.getPosition().y); moveBackground0Camera(player.getPosition().x, player.getPosition().y); moveBackground1Camera(player.getPosition().x, player.getPosition().y); cameraMatrixCopy.set(foregroundCamera.combined); rayHandler.setCombinedMatrix(cameraMatrixCopy.scale(Globals.BOX_TO_WORLD, Globals.BOX_TO_WORLD, 1.0f), foregroundCamera.position.x, foregroundCamera.position.y, foregroundCamera.viewportWidth * camera.zoom * Globals.BOX_TO_WORLD, foregroundCamera.viewportHeight * foregroundCamera.zoom * Globals.BOX_TO_WORLD); rayHandler.update(); rayHandler.render(); lightMap = rayHandler.getLightMapTexture(); fbo.begin(); { Gdx.gl.glClearColor(0, 0, 0, 0); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); /* Draw the second background (affected by lights), the player, the enemies and all the objects */ batch.enableBlending(); batch.setProjectionMatrix(background1Camera.combined); batch.begin(); background1.draw(batch); batch.end(); batch.setProjectionMatrix(foregroundCamera.combined); batch.begin(); // Draw stuff... batch.end(); } fbo.end(); /* Now let's pile things up: draw the bottom-most layer */ batch.setProjectionMatrix(background0Camera.combined); batch.disableBlending(); batch.begin(); background0.draw(batch); batch.end(); /* Blend the frame buffer's texture with the light map in a fancy way */ Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0); fboRegion.getTexture().bind(); // fboRegion = new TextureRegion(fbo.getColorBufferTexture()); Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE1); lightMap.bind(); Gdx.gl20.glEnable(Gdx.gl20.GL_BLEND); Gdx.gl20.glBlendFunc(Gdx.gl20.GL_SRC_ALPHA, Gdx.gl20.GL_ONE_MINUS_SRC_ALPHA); lightShader.begin(); lightShader.setUniformf("ambient_color", level.getAmbientLightColor()); lightShader.setUniformi("u_texture0", 0); lightShader.setUniformi("u_texture1", 1); fullScreenQuad.render(lightShader, GL20.GL_TRIANGLE_FAN, 0, 4); lightShader.end(); Gdx.gl20.glDisable(Gdx.gl20.GL_BLEND); Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0); // Bind again the default texture unit /* Draw any top-most layers you might have */ hud.draw(); }行。用于(固定)代码的x86类库构建的Dependency Walker说:

enter image description here

问题的最明显原因可能来自NuGet page for the library

  

您必须将平台目标设置为x86,ia64或x64。 AnyCPU程序集无法导出函数。