如下圖所示:
specialFont.cs有個方法要訪問“楷體_GB2312.ttf”資源,寫法如下,卻得到的是一個“null”百思不得其解,原來寫錯了:
String projectName = Assembly.GetExecutingAssembly().GetName().ToString();
Stream stmFont = Assembly.GetExecutingAssembly().GetManifestResourceStream(projectName+".Resources" +".楷體_GB2312.ttf");
應該寫成一下:
String projectName = Assembly.GetExecutingAssembly().GetName().Name.ToString();
Stream stmFont = Assembly.GetExecutingAssembly().GetManifestResourceStream(projectName+".Resources" +".楷體_GB2312.ttf");
另外,“楷體_GB2312.ttf”的屬性必須以 “嵌入的資源”作為資源文件。設置只需要在對應屬性框設置就是了。