我有一个wpf应用程序,我试图引用我创建的类库.我添加了对.dll的引用我已经将using语句添加到我的文件中,而intellisense实际上看到了新的命名空间.
然后在我的代码中,我能够在添加的.dll中创建新的类对象.intellisense看到所有方法ect..no问题,没有错误.
当我尝试构建我的wpf应用程序时,突然间我得到的类型或命名空间无法在我添加的dll上找到错误.
然后,每当我尝试从该.dll创建对象时,我都会收到错误.
我没有得到正在发生的事情..为什么它在我构建之前工作,但是当我构建它时决定它不知道我在哪里推荐.dll?
此外,我已经去了我想要添加的类库,并确保它构建没有错误.
我有一个列表,Games
其中只有a ID
,a Date
和a Time
.我将此列表设置为DataContext
.
然后,我有一个DataTemplate
这样的游戏:
<DataTemplate DataType="{x:Type loc:Game}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Name="dateBlock" Grid.Column="0" Grid.Row="1"
Text="{Binding Date, StringFormat=d}"></TextBlock>
<TextBlock Name="TimeBlock" Grid.Column="1" Grid.Row="1"
Text="{Binding Time}"></TextBlock>
//need to but a button here for each row
</Grid>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
要使用模板,我只是这样做:
<ListBox ItemsSource="{Binding}"></ListBox>
Run Code Online (Sandbox Code Playgroud)
我需要Button
在此列表视图中的每一行添加一个具有相同点击事件的行,但会以某种方式传递点击该按钮的游戏的ID.
我怎样才能做到这一点?我被卡住了.如果它没有意义让我知道,我会尝试更好地解释.
我正在使用以下内容
Task.Factory.StartNew(() => DoPrintConfigPage(serial));
Run Code Online (Sandbox Code Playgroud)
然后我调用的函数看起来像这样
private void DoPrintConfigPage(string serial)
{
//do printing work
}
Run Code Online (Sandbox Code Playgroud)
我的问题是在线程内部抛出异常并且没有被处理.
我试过用try catch包装它
try
{
Task.Factory.StartNew(() => DoPrintConfigPage(serial));
}
catch (Exception ex) { }
Run Code Online (Sandbox Code Playgroud)
但它仍然没有捕获错误,从而导致应用程序崩溃.
如何在主线程中捕获异常以便我可以处理它们?
我已经做了下面推荐的更改,但仍然说这个例外是未处理的
var task = Task.Factory.StartNew(() => DoPrintConfigPage(serial))
.ContinueWith(tsk =>
{
MessageBox.Show("something broke");
},TaskContinuationOptions.OnlyOnFaulted);
Run Code Online (Sandbox Code Playgroud)
然后在我的DoConfigPage
我添加另一个尝试捕获.
在这个问题现在崩溃,并说抛出的异常是未处理的,我错过了什么?
private void DoPrintConfigPage(string serial)
{
try
{
//call the print function
}
catch (Exception ex)
{
throw ex; //it is crashing here and saying it is unhandled
}
}
Run Code Online (Sandbox Code Playgroud)
我也尝试了Eric J.所提出的相同结果
var …
Run Code Online (Sandbox Code Playgroud) 我正在为asp.net MVC创建一个自定义动作过滤器.
在OnActionExecuting()
方法中.
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
string userName = ?????// how can I get this?
}
Run Code Online (Sandbox Code Playgroud)
我需要找出当前的用户名(我正在使用表单身份验证)
在控制器中我可以简单地做 User.Identity.Name
有没有办法在ActionFilter中获取用户名?
我有以下网格
<DataGrid
x:Name="TablesDataGrid"
Grid.Column="0"
Grid.Row="1"
ItemsSource="{Binding FilteredModels.View}"
AlternationCount="2"
AutoGenerateColumns="False"
CanUserSortColumns="True"
CanUserReorderColumns="False"
CanUserDeleteRows="False"
CanUserAddRows="False"
SelectionMode="Extended"
IsReadOnly="False"
SelectionUnit="FullRow"
RowHeight="25"
HorizontalAlignment="Stretch"
ColumnWidth="Auto">
<DataGrid.Columns >
<DataGridCheckBoxColumn Width="*" Binding="{Binding IsChecked, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" IsReadOnly="False">
<DataGridCheckBoxColumn.HeaderTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.CheckAll}"/>
</DataTemplate>
</DataGridCheckBoxColumn.HeaderTemplate>
</DataGridCheckBoxColumn>
<DataGridTextColumn Header="Source Table" Binding="{Binding SourceTableFullName}" Width="4*"></DataGridTextColumn>
<DataGridTextColumn Header="EDW Schema" Binding="{Binding SchemaName}" Width="2*"></DataGridTextColumn>
<DataGridTextColumn Header="EDW Table" Binding="{Binding TableName}" Width="4*"></DataGridTextColumn>
<DataGridTextColumn Header="Status" Binding="{Binding Status}" Width="*"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)
然后我有一个seachCommand在viewmodel中对collectionViewSource FilteredModel执行搜索,然后调用
this.FilteredModels.View.Refresh();
Run Code Online (Sandbox Code Playgroud)
当用户检查一些复选框并将网格发送到editmode然后执行搜索时,我们会收到以下错误
WPF DataGrid 'Refresh' is not allowed during an AddNew or EditItem …
Run Code Online (Sandbox Code Playgroud) 我知道之前已经问过这个问题,但是没有一个选定的答案对我有用.
我正在尝试使用@ViewChild从dom中获取我的ng-select.它总是返回undefined
这是main.html里面的选择
<ng-select id="user-select"
#userSelect
[allowClear]="true"
[items]="singleSignOnUsers"
[disabled]="disabled"
placeholder="No user selected">
</ng-select>
Run Code Online (Sandbox Code Playgroud)
这是我的组件
import { Component, AfterViewInit, ViewChild } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'app-main',
templateUrl: '../app/main.html',
providers: [ApiHttpService, UserAdministrationService]
})
export class AppComponent {
@ViewChild('userSelect') userSelect;
ngAfterViewInit() {
alert(this.userSelect);
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里失踪了什么?
更新:哦,我的灵魂!我想出了为什么这不应该工作时...我将整个视图包含在带有ngSwitch的div中.如果我把它移出......我可以访问它们.现在我不知道如何在ngSwitch中访问它们.但我不必使用ngSwitch
<div [ngSwitch]='loading'>
<div *ngSwitchCase="false">
...
<ng-select id="user-select"
#userSelect
[allowClear]="true"
[items]="singleSignOnUsers"
[disabled]="disabled"
placeholder="No city selected">
</ng-select>
...
</div>
<div
Run Code Online (Sandbox Code Playgroud) 这应该很简单,但我无法在任何地方找到答案.在我们的asp.net MVC网站上,我们显示货币值,无论用户文化设置如何,我都需要这些货币值始终为美元.
如果我使用string.format("{0:C}",value),那么它会显示用户设置的文化中的值.这对我们来说是不正确的,因为$ 1000.00与1000.00欧元不同
I still need to use the language side of this, meaning if they are in France I want to use the French localization resource, so I don't want to completely disregard their culture settings, but how can I make sure the currency is always shown in USD?
我正在使用 openXml SDK 创建一个简单的 word 文档。到目前为止它正在工作。现在如何将文件系统中的图像添加到此文档?我不在乎它在文档中的哪个位置,只是因为它就在那里。谢谢!这是我到目前为止所拥有的。
string fileName = "proposal"+dealerId +Guid.NewGuid().ToString()+".doc";
string filePath = @"C:\DWSApplicationFiles\Word\" + fileName;
using (WordprocessingDocument wordDoc = WordprocessingDocument.Create(filePath, WordprocessingDocumentType.Document, true))
{
MainDocumentPart mainPart = wordDoc.AddMainDocumentPart();
mainPart.Document = new Document();
//create the body
Body body = new Body();
DocumentFormat.OpenXml.Wordprocessing.Paragraph p = new DocumentFormat.OpenXml.Wordprocessing.Paragraph();
DocumentFormat.OpenXml.Wordprocessing.Run runParagraph = new DocumentFormat.OpenXml.Wordprocessing.Run();
DocumentFormat.OpenXml.Wordprocessing.Text text_paragraph = new DocumentFormat.OpenXml.Wordprocessing.Text("This is a test");
runParagraph.Append(text_paragraph);
p.Append(runParagraph);
body.Append(p);
mainPart.Document.Append(body);
mainPart.Document.Save();
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用TFS2010 Build.TFS构建一个项目驻留在自己的服务器上,我正在尝试构建到同一台机器上的目录.服务器上没有安装VS2010.当构建运行时它失败并给我这个错误:
c:\ Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1558):任务失败,因为找不到"AxImp.exe",或者未安装正确的Microsoft Windows SDK.任务是在注册表项HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A的InstallationFolder值中指定的位置下的"bin"子目录中查找"AxImp.exe".您可以通过执行以下操作之一来解决问题:1)安装Microsoft Windows SDK.2)安装Visual Studio 2010. 3)手动将上述注册表项设置为正确的位置.4)将正确的位置传递给任务的"ToolPath"参数.
然后我得到一大堆错误,说无法找到我正在构建的项目的名称空间.我不确定这是否与上述错误有关.
谢谢!
在我的jqgrid中,我有一个单元格中有链接.当前用户单击此链接时,行被选中(我使用的是多选)我不想这样,有没有办法在用户选择行时用链接点击这个特定的单元格?我已经考虑过做一个onCellSelect,然后查看是否选中了当前的单元格并将其设置回单击单元格之前的状态.不确定这是不是最好的方式,或者甚至是可能的.我找不到检查当前行是否被选中的方法,如果选择了某行,也无法找到更改方法.任何想法都会有帮助.谢谢!
我将通过Azure存储教程中的Azure存储帐户查看blob 教程
我已经在azure上创建了存储帐户,它说它已经启动了.我已将密钥和帐户名复制到配置文件中.我已经验证我的应用程序中的端点地址与我的azure存储帐户中的端点地址匹配.但是当我运行代码时出现404错误.当我从我的azure帐户复制并通过端点地址到浏览器时,我也收到404错误
这里是我的代码.实际上从教程中复制我确实添加了正确的帐户名称和密钥到配置字符串,但删除了这篇文章
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");
// Create or overwrite the "myblob" blob with contents from a local file.
using (var fileStream = System.IO.File.OpenRead(@"myfile"))
{
blockBlob.UploadFromStream(fileStream);
}
Run Code Online (Sandbox Code Playgroud)
和连接字符串
<appSettings>
<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myAccount;AccountKey=mykey" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?我需要在Azure中做更多的事情吗?
试图发布到introspect方法是一个错误的请求错误:
"Bad request. Accept and/or Content-Type headers likely do not match supported values."
Run Code Online (Sandbox Code Playgroud)
这是我打的网址
..oauth2/v1/introspect?token_type_hint=access&token={token}&client_id={ClientId}&client_secret={ClientSecret}"
Run Code Online (Sandbox Code Playgroud)
我正在设置内容类型并接受标题为"application/json"
如果这些不正确,则没有文件说明它们应该是什么.
我们在 IIS 中运行我们的 angular 应用程序作为虚拟应用程序“myapplication”
在我们的 angular 应用程序中,我在 index.html 中设置了:
<base href="/myapplication/">
Run Code Online (Sandbox Code Playgroud)
它在 IIS 中运行良好。但是现在NG服务不起作用。因为它无法在http://localhost/myapplication/下找到所有包,因为 CLI 没有在该路径下运行。
我试过了
ng serve --base-href /myapplication/
Run Code Online (Sandbox Code Playgroud)
并浏览到http://localhost:4200/myapplication/
我仍然看到相同的错误。
我如何告诉 CLI 在“ http://localhost:4200/myapplication/ ”下为应用程序提供服务?
c# ×5
.net ×3
wpf ×3
angular ×2
asp.net-mvc ×2
angular-cli ×1
asp.net ×1
datatemplate ×1
jqgrid ×1
jquery ×1
listview ×1
localization ×1
mvvm ×1
okta ×1
openxml ×1
openxml-sdk ×1
tfs ×1
tfs2010 ×1
wpfdatagrid ×1
xaml ×1