相关疑难解决方法(0)

CLR会处理CLS-Complaint和非CLS投诉异常吗?

仅供我澄清:

我可以在.NET Framework中抛出CLS-Complaint和非CLS投诉异常吗?.我正在使用C#3.0.

当我抓住异常

catch(Exception ex)
{

}
Run Code Online (Sandbox Code Playgroud)
  • 它只会捕获CLS-Complaint异常吗?
  • RuntimeWrappedException类有什么用(我可以举一个简单的例子吗?).

c# asp.net exception-handling

8
推荐指数
1
解决办法
2375
查看次数

在C#中处理来自非托管dll的异常

我有用C#编写的以下函数

public static string GetNominativeDeclension(string surnameNamePatronimic)
{
    if(surnameNamePatronimic == null) 
       throw new ArgumentNullException("surnameNamePatronimic");

IntPtr[] ptrs = null;
try
{
    ptrs = StringsToIntPtrArray(surnameNamePatronimic);

    int resultLen = MaxResultBufSize;
    int err = decGetNominativePadeg(ptrs[0], ptrs[1], ref resultLen);
    ThrowException(err);
    return IntPtrToString(ptrs, resultLen);
}
catch
{
    return surnameNamePatronimic;
}
finally
{
    FreeIntPtr(ptrs);
}
Run Code Online (Sandbox Code Playgroud)

}

函数decGetNominativePadeg在非托管dll中


[DllImport("Padeg.dll", EntryPoint = "GetNominativePadeg")]
private static extern Int32 decGetNominativePadeg(IntPtr surnameNamePatronimic,
    IntPtr result, ref Int32 resultLength);

并抛出异常: Attempted to read or write protected memory. This is often an indication that other memory …

Run Code Online (Sandbox Code Playgroud)

c# dll unmanaged

6
推荐指数
1
解决办法
7596
查看次数

标签 统计

c# ×2

asp.net ×1

dll ×1

exception-handling ×1

unmanaged ×1