3

I am adding a dll for my project. My project is in vb.net and dll is written in c#.net. When I add this to a vb.net project the properties that are available are different (less in number) to the properties that are available if the same dll is added to a c# project.

Object Browser view when added to a VB.Net Project enter image description here

Object Browser view when added to a c# project Object Browser view when added to a c# project

If you see in c# view you can access properties like "hits" and "facets" which are not accessible in vb.net.

Can anyone please help me understand this issue.

4

3 に答える 3

0

私の状況を明確にするために、github からダウンロードした dll を使用しています。github からソース コードをダウンロードしたところ、CLSComplaint ではないことがわかりました。プロパティ名を変更し、DataMember 属性 (jsonserilzation 用) を追加すると、vb.net プロジェクトでもすべてのプロパティを使用できますが、直面する問題は、元の特定のクラス ライブラリの更新にコードの変更をマージすることです。作成者と話すまで、GitHub にコミットしたくない CLSComplaint のバージョン。

回避策として、GetHitCount(CLSComplaint プロパティ名) を追加しました

public int GetHitCount
{
    get { return hits.total;}
}

これにより、dll が vb.net プロジェクトに追加されたときに使用できない「ヒット」プロパティが公開されます。

于 2013-06-17T14:51:59.593 に答える
0

C# プロジェクトの "ヒット" と "ファセット" には、同じ名前で大文字と小文字が異なるクラスのメンバーが含まれている可能性があります。これは、C# dll を参照する VB プロジェクトでは非常に一般的な問題であり、C# dll が CLS に準拠していないという結果にもなります。VB は大文字と小文字を区別しないため、"Hits" メンバーも存在する場合、どの "ヒット" が必要かを判断できません。その結果、VB はどちらのメンバーも表示しません。

「ヒット」と「ファセット」は引き続き呼び出すことができますが、これを行うには「InvokeMember」を使用する必要があります (リフレクションを使用)。

于 2013-06-17T15:03:52.243 に答える