1

埋め込みリソース (実行中のアセンブリに含まれる) を取得しました。次のコマンドで取得できます。

Assembly.GetExecutingAssembly().GetManifestResourceStream("<MyNamespace>.<File>")

アセンブリの名前空間が変更された場合、文字列に含まれるすべての場所を見つける必要があります。これを避けるために、名前空間を動的に取得したいと思います。アセンブリの名前空間を取得したり、固定値を使用したりする可能性はありますか?

返信ありがとうございます。

4

1 に答える 1

4

You could define a dummy type within that namespace, and extract the namespace from that type:

public class TestType
{
}

var obj = new TestType();
var ns = obj.GetType().Namespace;

EDIT: of course this is a good solution if the namespace is part of your existing assembly and you have access to the source of it

于 2013-04-16T16:55:35.480 に答える