小编And*_*rey的帖子

将Web Api服务自托管到Windows窗体中

我试图使用下面的代码在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应用程序内自托管?

c# asp.net self-hosting winforms asp.net-web-api

11
推荐指数
2
解决办法
5627
查看次数

DataGridView - 使用DataPropertyName显示子元素属性

让图像我有以下类

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)

列显示在网格中,但没有值

c# datagridview winforms

10
推荐指数
2
解决办法
2万
查看次数

MSBuild未生成发布网页(ClickOnce)

我遇到的问题是,当我通过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)

有任何想法吗?

谢谢

.net c# msbuild clickonce publish

10
推荐指数
1
解决办法
5581
查看次数

WIA 2.0 复式房产

我正在使用 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)

c# wia imaging duplex

5
推荐指数
1
解决办法
9864
查看次数