我试图从ASP.NET应用程序中调用我的服务中的方法,如下所示.
public bool ValidateUser(string username, string password)
{
try
{
// String CurrentLoggedInWindowsUserName = WindowsIdentity.GetCurrent().Name;
// //primary identity of the call
// String CurrentServiceSecurityContextPrimaryIdentityName =
// ServiceSecurityContext.Current.PrimaryIdentity.Name;
//
}
catch (Exception ex)
{
FaultExceptionFactory fct = new FaultExceptionFactory();
throw new FaultException<CustomFaultException>(fct.CreateFaultException(ex));
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
我的服务客户端的配置如下
<binding name="WSHttpBinding_IMembershipService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="false" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" /> …Run Code Online (Sandbox Code Playgroud) 我在Visual Studio中创建了一个空的C#项目,并添加了一个类。然后,我添加了对System.Data.Entity dll的引用。我将一个类添加到我的项目中,然后如下所示编写了一个DbContext对象。但是,我收到以下错误信息。我还需要引用其他哪些dll才能使用它?
错误1类型或名称空间名称'DbContext'在名称空间'System.Data.Entity'中不存在(您是否缺少程序集引用?)
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Data.Entity;
namespace Budget.Data
{
public class BudgetContext : System.Data.Entity.DbContext
{
}
}
Run Code Online (Sandbox Code Playgroud) 我有以下代码从excel文件中读取数据,我遇到的问题是,当我尝试读取范围数据时,我得到一个异常"无法在此行上对空引用执行运行时绑定"
if (Int32.TryParse(xlRange.Cells[1, 4].Value2.ToString(), out value))
Run Code Online (Sandbox Code Playgroud)
我想知道的是我如何正确访问该范围内的信息.提前致谢
void ReadFromExcelToGrid2(String fileNameString)
{
try
{
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(fileNameString);
//get list of worksheets associated with the current workbook
Microsoft.Office.Interop.Excel.Sheets worksheets = xlWorkbook.Worksheets;
//list the work books in a dropdownlist
IDictionary<int, String> sheets = new Dictionary<int, String>();
foreach (Microsoft.Office.Interop.Excel.Worksheet displayWorksheet in xlWorkbook.Worksheets)
{
sheets.Add(displayWorksheet.Index, displayWorksheet.Name);
}
cmbWorksheets.DataSource = new BindingSource(sheets, null);;
cmbWorksheets.DisplayMember = "Value";
cmbWorksheets.ValueMember = "Key";
Microsoft.Office.Interop.Excel.Worksheet xlWorksheet = xlWorkbook.Sheets[4]; // assume it is the first sheet …Run Code Online (Sandbox Code Playgroud) 我正在办公室的Offiice Access工作.我注意到没有很多控件可供使用,但我要求在结构(不是列表框或组合框)的表格中显示数据.我怎么能做到这一点呢?
我正在尝试创建一个列表类来处理和引发PropertyChanged任何属性更改时的事件.
我的主类包含3个列表,其中包含3种不同类型的项目
我希望能够做类似的事情
public class MainClass : INotifyPropertyChanged
{
public CustomList<TextRecord> texts{get; set;};
public CustomList<BinaryRecord> binaries{get; set;};
public CustomList<MP3Record> Mp3s{get; set;};
//implement INotifyPropertyChanged
}
public class CustomList<T> where T:(TextRecord, BinaryRecord, MP3Record)
{
//code goes here
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能将这个限制放在我的CustomList类上呢?提前致谢.
我有两个基本上是类库项目的项目.One(Net.Data.Entities)包含我使用的实体的定义,而另一个类Project(Net.Data.DataContexts)包含我的应用程序要使用的数据上下文对象.Net.Data.DataContects项目具有对Net.Data.Entities项目的引用.当我构建我的库,它们都在属性部分中设置为类库时,我收到以下错误消息
**错误2元数据文件'C:...\XXX\XXXXX\Net.Data.Entities\bin\Debug\Net.Data.Entities.exe'找不到
错误1程序'c:...\XXX\XXXXX\Net.Data.Entities\obj\Debug\Net.Data.Entities.exe'不包含适用于入口点的静态'Main'方法**
以上是什么意思,我该如何解决这个问题呢?我正在使用Entity Framework 5和.NET 4.5在Windows 7计算机上运行或使用Visual Studio 2012.
我有一个方法允许用户指定一个远程目录和一个searchPattern with with来搜索远程目录中的文件.由于我在从远程位置检索文件名时使用第三方库,因此无法利用System.IO的Directory.GetFiles()例程,该例程允许我在获取文件时指定searchPattern.
Basic String.Compare与提供的模式的文件名不匹配.有人知道更有效的匹配方式吗?
public IList<String> GetMatchingRemoteFiles(String SearchPattern, bool ignoreCase)
{
IList<String> matchingFileNames = new List<String>();
var RemoteFiles = thirdPartyTool.ftpClient.GetCurrentDirectoryContents();
foreach( String filename in RemoteFiles)
if( String.Compare(filename, SearchPattern, ignoreCase) == 0)
matchingFileNames.Add(filename);
return matchingFileNames;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我需要知道如何在我的存储过程中关闭ANSI警告.我一直在收到错误
字符串或二进制数据将被截断.
但是,我希望关闭它,以便我期待这一点,而宁愿允许它.
我补充说
SET ANSI_WARNINGS OFF
GO
Run Code Online (Sandbox Code Playgroud)
然而,在存储过程之前,执行此操作似乎根本不会抑制错误.
由于我开始使用此截断错误的原因,我的一个存储过程执行动态Sql以检索值(SQLFIddle显示代码).我必须将所有字段的长度设置为最大长度(NVarchar(3072)).然而,当执行我的查询时,我需要将它们打印到正确的大小,然后将它们打印到客户端.
非常感谢如何最好地处理这个问题.提前致谢.
我有以下结构来管理相机状态
struct keyState
{
float x_rotation, y_rotation, z_rotation;
float x_rotation_rad, y_rotation_rad, z_rotation_rad;
float x_pos, y_pos, z_pos;
} state_manager;
Run Code Online (Sandbox Code Playgroud)
该结构位于我的WalkingCameraManipulator.h类中。WalkingCameraManipulator在WalkingCameraManipulator.cpp中实现,我的主类中有一个#include“ WalkingCameraManipulator”。
错误1错误LNK2005:在main.obj中已经定义了“ struct keyState state_manager”(?state_manager @@ 3UkeyState @@ A)错误2错误LNK1169:找到一个或多个乘法定义的符号
但是,我正在处理以下错误消息,需要找到适合我的结构的最佳位置。关于我在这里可以做什么的任何想法?提前致谢。
我有一个对象实例。在对象的构造函数中,我希望允许用户传入一个字典,用它来初始化对象的一些(如果不是全部)属性。现在,我不想使用条件,而是使用反射,反射对象实例中包含的属性,如果属性名称映射到字典中的键,则使用相应的值更新属性值在字典中。
在处理此问题时,我有以下代码,但它不会更新我的对象实例的值。希望您能提供一些帮助让其正常工作吗?
public void Initialize()
{
if (Report.GlobalParameters != null)
{
PropertyInfo[] propertyInfos = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo propertyInfo in propertyInfos)
{
if (Report.GlobalParameters.ContainsKey(propertyInfo.Name))
{
Type type = this.GetType();
PropertyInfo property = type.GetProperty(propertyInfo.Name);
property.SetValue(this, Report.GlobalParameters[propertyInfo.Name], null);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)