Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a dll with reference to a nuget library #101

Closed
fxl447098457 opened this issue May 31, 2019 · 4 comments
Closed

create a dll with reference to a nuget library #101

fxl447098457 opened this issue May 31, 2019 · 4 comments
Labels

Comments

@fxl447098457
Copy link

fxl447098457 commented May 31, 2019

here are the codes.i tried the dll in vba. class worked with the CreateIm method not available.error info:“QRCoder, Version=1.3.5.0, Culture=neutral, PublicKeyToken=null” or one of its dependencies. The system cannot find the file specified. could you give me some advice.many thx.

`using QRCoder;
using System;
using System.Drawing;
using System.Runtime.InteropServices;

namespace Qrcode
{
[ComVisible(true), ClassInterface(ClassInterfaceType.AutoDual)]
public class myqrcode
{
[return: MarshalAs(UnmanagedType.SysInt)]
public int CreateIm([MarshalAs(UnmanagedType.BStr)]string s, [MarshalAs(UnmanagedType.BStr)]string filePath)
{
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode(s, QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(5, Color.Black, Color.White, null, 15, 6, false);
qrCodeImage.Save(filePath);
return 0;
}
}
static class UnmanagedExports
{
[DllExport]
[return: MarshalAs(UnmanagedType.IDispatch)]
static Object CreateQrcodeClass()
{
return new myqrcode();
}
}
}
`

@3F
Copy link
Owner

3F commented May 31, 2019

@fxl447098457 This is [ probably ] what you need: #86 (comment)
Because I'm not sure what you're talking about at all. Does this have a bug or just a question.

Can you ask more clearly if it's not, sorry.

@fxl447098457
Copy link
Author

@3F just a question. it seems that 3rd dll does not work.should i use assembly to load the library just like #86?look forward to your reply.

@3F 3F added the question label Jun 3, 2019
@3F
Copy link
Owner

3F commented Jun 3, 2019

An assemblyResolve as one of the options. Follow my recommendations there with the user's example from last reply.

You need to try to use a common practice when debugging third-party libraries, look here: #84 (comment)

  • /Examples/DllExport/BasicExport also illustrates structure for catching errors together with interactive debugging at runtime. That is, you also can try to adapt this code for checking any caused errors in your case.

@fxl447098457
Copy link
Author

fxl447098457 commented Jul 4, 2019

sorry for my late feedback.assemblyreslove did work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants