- Home /
Referencing a DLL in C#
I have created a .dll file that sets up printing capabilities and now I want to be able to reference the function in my C# code (on a button press)
My .dll is as follows:
using Android.Print;
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Graphics;
using Android.Print.Pdf;
using System.IO;
namespace PrintIMPORTteste
{
public class PrintActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Print);
var txtview = FindViewById<TextView>(Resource.Id.textview1);
txtview.Text = "Hello";
var button = FindViewById<Button>(Resource.Id.button1);
button.Click += (object sender, EventArgs e) = > {
var printManager = (PrintManager)GetSystemService(Context.PrintService);
var content = FindViewById<LinearLayout>(Resource.Id.linearLayout1);
var printAdapter = new GenericPrintAdapter(this, content);
printManager.Print("MyPrintJob", printAdapter, null);
};
}
}
}
float add(float x, float y)
{
return x + y;
}
I then call the .dll in my C# code by using:
[DllImport("native")]
From there I don't know how to reference the 'OnCreate' void.
I understand you can access the float add (at the bottom of the .dll) using:
private static extern float add(float x, float y);
Any help would be appreciated
Comment