通过C#访问c ++ dll中的fscanf() [英] accessing fscanf() in c++ dll through C#

查看:86
本文介绍了通过C#访问c ++ dll中的fscanf()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在C#应用程序中使用C ++(MFC)dll。当我尝试使用不同的说明符访问fstream()函数(来自DLL)时,我的应用程序关闭。示例代码在这里给出:

1)fscanf(fp,%1c,&冒号); :这很好用

2)fscanf(fp,%2x,&byte_count); :我的应用程序已关闭。



但如果我单独执行我的C ++应用程序它会工作正常,如果我在c#应用程序中使用dll则无法调用它。它不会抛出任何错误或异常(因为该方法在DLL中)。但只是关闭。任何人都可以给出解决方案吗?或任何想法找出生成的日志文件,以找出错误??



谢谢,



Vinod

Hi,

I am using C++(MFC) dll in my C# application. My application getting closed when i tried to access fstream() function (from DLL )with different specifier. sample code is given here:
1) fscanf(fp,"%1c",&colon); :this works fine
2) fscanf(fp,"%2x",&byte_count); : My application got closed.

But it will work fine if i execute my C++ application individually, and not able to call it if i use through dll in my c# application. It is not throwing any error or exception(since the method is in DLL).But simply getting closed. Can anybody give the solution?? or any idea to figure out the log file generated to find out the errors??

thanks,

Vinod

推荐答案

可能是你的DLLImport语句以及从C#代码中传入的实际参数 - 我们看不到,但你应该看看at。



但是你为什么要从C#调用fscanf?
Probably, it's down to your DLLImport statements and the actual parameters you pass in from the C# code - which we can't see, but you should look at.

But why would you want to call fscanf from C#?


实际上我需要为一个ST转换C ++代码登上C#。相反,我只是使用C ++ DLL。 C ++代码可在以下站点中找到。解决方案名称'DfuSe'。 http://www.st.com/web/en/catalog/工具/ FM147 / CL1794 / SC961 / SS1533 / PF257916 [ ^ ]
actually i need to convert C++ code for one ST board into C#. instead i just making use of the C++ dll. The C++ code is available in the following site. Solution name 'DfuSe'. http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1533/PF257916[^]


这篇关于通过C#访问c ++ dll中的fscanf()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆