我试图使用下面的代码在Windows窗体应用程序中自我托管Web Api服务
namespace MascoteAquarium.Desktop
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
var config = new HttpSelfHostConfiguration("http://localhost:8080");
config.Routes.MapHttpRoute(
"DefaultApi", "api/{controller}/id", new { id = RouteParameter.Optional });
using (HttpSelfHostServer server = new HttpSelfHostServer(config))
{
server.OpenAsync().Wait();
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMainMenu());
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试
http://localhost:8080/api/*(some-controller)*
Run Code Online (Sandbox Code Playgroud)
我在System.Web.Http.SelfHost.HttpSelfHostServer.ProcessRequestContext(ChannelContext channelContext,RequestContext requestContext)收到NullReferenceException.
有人知道发生了什么事吗?是否有可能在Win Forms应用程序内自托管?
让图像我有以下类
public class Master
{
public string MasterName = "Something";
public List<Detail> details = new List<Detail>();
}
public class Detail
{
public string Foo = "Test";
}
Run Code Online (Sandbox Code Playgroud)
然后我想使用下面的代码在DataGridView中显示Details对象的集合
DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn();
column.DataPropertyName = "Details.Foo";
column.HeaderText = "Foo header";
dgv.Columns.Add(column);
Run Code Online (Sandbox Code Playgroud)
列显示在网格中,但没有值
我遇到的问题是,当我通过MSBuild(4.0)发布ClickOnce应用程序时,不会在app.publish文件夹中创建publish.htm(或default.htm).
通过Visual Studio发布时,它会被创建...
在我的.csproj文件中,我设置了以下属性,但它仍然无效...
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>default.htm</WebPage>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢
我正在使用 C# 开发一个应用程序来使用 WIA 2.0 库。目前我可以使用大部分功能,例如 ADF(自动文档进纸器)、过滤器等等。
现在,我需要使用扫描仪(富士通)的双面打印器。
我正在尝试将 WIA_DPS_DOCUMENT_HANDLING_SELECT 扫描仪属性设置为 DUPLEX 值。请参阅下面的代码:
try
{
bool hasMorePages = false;
//determine if there are any more pages waiting
Property documentHandlingSelect = null;
Property documentHandlingStatus = null;
foreach (Property prop in WiaDev.Properties)
{
if (prop.PropertyID == WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_SELECT)
documentHandlingSelect = prop;
if (prop.PropertyID == WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_STATUS)
documentHandlingStatus = prop;
}
object obj = new object();
obj = (WIA_DPS_DOCUMENT_HANDLING_SELECT.DUPLEX);
documentHandlingSelect.set_Value(ref obj);
if (documentHandlingSelect != null) //may not exist on flatbed scanner but required for feeder …Run Code Online (Sandbox Code Playgroud)