如果在引用的dll中使用Application.StartupPath,則路徑指向IDE的路徑。如何在winforms,.net中的設計時獲得應用程序路徑?
是否有無法獲得實際應用程序的路徑?
只是要清楚,這是在設計時。
ETA:我已經發布了以下的解決方案:
ETA2:
因爲它是相關的,我想我會發布另一個有用的設計時服務的一個片段。像下面的解決方案一樣,此示例適用於UITypeEditor:
Public Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal value As Object) As Object
Dim typeDiscovery As ITypeDiscoveryService = TryCast(provider.GetService(GetType(ITypeDiscoveryService)), ITypeDiscoveryService)
Dim types As ICollection = typeDiscovery.GetTypes(GetType(MyType), False)
End Function
類型將包含從MyType派生的所有類型。將第二個參數更改爲True以排除搜索GAC。 傳遞Nothing作爲獲取所有類型列表的第一個參數。
OP正在尋找如何在設計時間做到這一點,即在贏得表格設計師......而不是在運行時... – t0mm13b 2010-01-24 02:53:31