回答
您可以將Add existing item
a .resx
文件轉換爲F#項目,它應該會自動獲得BuildAction
的EmbeddedResource
並開始工作。這裏的VS工具不如其他語言好,但MSBuild完成所有繁重的工作,所以這只是將正確的XML片段放到.fsproj文件中的問題。
我在F#2.0項目中使用.resx。隨意看看它,我希望它可以幫助你。沒有很大的震動,但這是它的價值。
http://github.com/OnorioCatenacci/ExtendedSearch
編輯:對於它的價值,這裏的fsproj文件
<ItemGroup>
<Compile Include="assemblyinfo.ExtendedSearch.exe.fs" />
<Compile Include="ExtendedSearch.fs" />
<EmbeddedResource Include="ExtendedSearch.resx" />
</ItemGroup>
的相關部分而這裏的ExtendedSearch.resx:
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, ...</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, ...</value>
</resheader>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<data name = "AppDisplayName">
<value>Extended Search</value>
</data>
<data name="FilePathSpecLabel">
<value>Base File Path:</value>
</data>
<data name="FilePathSpecDefault">
<value>C:\</value>
</data>
<data name ="SelectDirButtonLabel">
<value>. . .</value>
</data>
<data name="FileNameSpecLabel">
<value>File Name Spec:</value>
</data>
<data name="FileNameSpecDefault">
<value>*.dll</value>
</data>
<data name="RecurseIntoSubdirsLabel">
<value>Recurse Into Subdirectories</value>
</data>
<data name ="MajorVerDefault">
<value>1</value>
</data>
<data name="MinorVerDefault">
<value>0</value>
</data>
<data name="RevisionVerDefault">
<value>0</value>
</data>
<data name="BuildVerDefault">
<value>0</value>
</data>
<data name="VersionLabel">
<value>File &Version:</value>
</data>
<data name="SearchButtonCaption">
<value>&Search</value>
</data>
<data name="CancelButtonCaption">
<value>&Cancel</value>
</data>
</root>
我希望這消除任何未來人們無法在GitHub上找到這些問題。
這是另一種方式。雖然我知道原來的問題已經太晚了,但我希望它能幫助其他人。
創建一個乾淨的文本文件,其名稱=值格式,每行一個鍵/值對。在一個名爲「strings.txt」文件,寫入
name1=hello name2=world
使用作用於從第1步文本文件ResGen.exe您可以在http://msdn.microsoft.com/en-us/library/ccec7sz1%28v=vs.80%29.aspx瞭解RESGEN創建一個資源文件。 ResGen將創建一個名爲「strings.resources」的CLR二進制文件。把這個資源文件放到你的編譯器可以找到的地方。
將「--resource:strings.resources」添加爲編譯器選項。我在「構建」屬性中的「其他標誌」文本框中執行了此操作。您可以在http://msdn.microsoft.com/en-us/library/dd233171.aspx
找到更多的信息寫在你的F#項目
open System.Resources let res = ResourceManager("strings", System.Reflection.Assembly.GetExecutingAssembly()) res.GetString("name1") + res.GetString("name2") |> printfn "%s"
要將資源添加到現有的F#項目,每@ 「Onorio Catenacci的」 GitHub Linke上面下面...
- 創建一個文本文件,並用下面的內容填充它,然後保存並關閉它。
- 重命名該文本文件擴展
.resx
(XML資源文件) - 更新
Build Action
到EmbeddedResource
- 該文件應該已經在VS資源編輯器允許你編輯它的內容正確打開。
.resx
文件模板:
<root>
<resheader name="resmimetype"><value>text/microsoft-resx</value></resheader>
<resheader name="version"><value>2.0</value></resheader>
<resheader name="reader"><value>System.Resources.ResXResourceReader, System.Windows.Forms, ...</value></resheader>
<resheader name="writer"><value>System.Resources.ResXResourceWriter, System.Windows.Forms, ...</value></resheader>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</root>
- 1. 資源管理在F#
- 2. 如何獲取在資源管理器或項目資源管理器中選擇的項目列表?
- 3. NetBeans項目的從資源管理器
- 4. TFS項目在源代碼管理資源管理器中可見,但不在團隊資源管理器中?
- 5. 項目管理 - 資源圖表
- 6. Solaris 9項目(資源管理)
- 7. Eclipse:在項目資源管理器中找不到項目
- 8. 項目資源管理器,帶孩子的項目
- 9. 管理目錄api中的資源ID
- 10. 如何管理CPU資源
- 11. 如何用TFS團隊資源管理器搜索項目?
- 12. 項目訂單Eclipse項目資源管理器視圖
- 13. 如何在Eclipse項目資源管理器右鍵菜單中添加項
- 14. 資源管理
- 15. 資源管理器如何獲取HAWQ中的資源?
- 16. Eclipse項目中的文件資源管理器
- 17. Eclipse中的項目資源管理器未顯示
- 18. 解決方案資源管理器中的選定項目
- 19. 列出谷歌雲資源管理器中的所有項目
- 20. Visual Studio源代碼管理資源管理器重複TFS項目文件夾
- 21. Symfony 2資產項目佈局和資源管理
- 22. Eclipse:在項目資源管理器中搜索文件夾和資源
- 23. XCode中的資源管理
- 24. tomcat中的資源管理
- 25. F#開源項目
- 26. 如何從資源項目
- 27. Eclipse開普勒:隱藏項目資源管理器中的特定項目
- 28. 管理不同的資源目錄
- 29. 如何在我的C#WinApp項目中打開服務器資源管理器?
- 30. 如何在包資源管理器中顯示較少的項目?
謝謝,我已經下了類似的路徑,手動編碼的資源管理器包裝。我現在想知道它是否會本地化將工作... – 2010-04-23 00:33:07
我會有興趣聽到本地化是否工作。我主要使用.resx因爲我想刷新我的記憶 - 我的.Net編碼技能有點生疏。 – 2010-04-23 00:54:05
我在鏈接到github後收到404錯誤:( – Joh 2013-01-22 12:48:39