【c# – Form.Show():无法访问已处置的对象】教程文章相关的互联网学习教程文章

c# – 无法访问其他项目中的公共类,但访问相同的命名空间【代码】

我的解决方案中有两个项目,每个项目都有一个包含公共类的CS文件.由于两个类都在同一个命名空间中,我希望它们能够看到对方.事实并非如此.请参阅下面的设置. 项目Woof1,文件File.CSnamespace MyNameSpace {public class Foo{// Doesn't compileFaa f;} }项目Woof2,文件File.CSnamespace MyNameSpace {public class Faa{// Doesn't compileFoo f;} }注意,两个类都存储在具有相同名称但位于不同目录(即不是同一文件)的文件中. >为什么我...

c# – 为什么在单元测试中无法访问该类?【代码】

我为一个名为game.cs的类中的方法创建了一个单元测试.出于某种原因,当我引用该类时,我无法创建新实例.如何使这个类可访问,以便我可以测试我的代码? 文件层次结构和解决方案:using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using BowlingKataTDD;namespace BowlingKataTDDTest {[TestClass]public class BowlingKataTDDUnitTests {[TestMethod]public void DoesGameExist(){//arrangeBowlingKataTDD.}} }Bow...

c# – Mono说’System.Net.Dns.GetHostEntry(string)’由于其保护级别而无法访问【代码】

我正在上课,其中一些例子在C#中.由于我的笔记本电脑运行Linux,我在Ubuntu上使用Mono 2.6.7. 我正在尝试编译以下代码:using System.Net.Sockets; using System.Net; using System;/// <summary> /// Example program showing simple TCP socket connections in C#.NET. /// Rather than reading and writing byte arrays, this example show /// how to use a stream reader in the client. /// TCPSocketServer is the socket ser...

c# – 无法访问aspx.cs页面上的webmethod【代码】

我试图用jquery ajax调用web方法.但是,该调用返回Not Found错误.尝试直接通过URL访问该方法也会返回404错误. 我确保将EnablePageMethods =“true”参数添加到< asp:ToolkitScriptManager>在母版页上. Announcements.aspx:<script type="text/javascript">$(function () {$("#CreateBtn").click(function () {var announce = {};announce["title"] = "An Announcement";announce["body"] = "Announcement Body";$.ajax({type: "PO...

c# – TFS Build失败,“无法访问文件* FakeTypesCache”【代码】

几天以来,我们遇到了TFS构建问题.我们使用Microsoft Shims / Fakes进行一些单元测试,到目前为止我们没有遇到任何问题.但最近UnitTest Step因以下错误而失败:每隔一段时间就会发生以下情况:2016-07-01T06:40:25.3532321Z ##[error]Error: System.IO.IOException: The process cannot access the file 'D:\Builds\Agent\87a4a39e\...\bin\Debug\mscorlib.4.0.0.0.Fakes.FakedTypesCache' because it is being used by another proc...

c# – WCF:无法访问已关闭的流【代码】

我正在尝试在WCF中接收Stream对象,但是当我收到它时,我得到一个封闭的Stream.以下是我的代码[OperationContract] string ProcessPackageUsingStream(FileStream stream, string fileName, string docType, string customerKey, int documentId);在实现中我正在使用此流对象.string ProcessPackageUsingStream(FileStream stream, string fileName, string docType, string customerKey, int documentId); {//Stream is closed here...

c# – ApiController扩展方法 – 无法访问ResponseMessage【代码】

我想为ApiController创建扩展方法,以便能够返回自定义内容.我的想法是用我自己的细节返回自定义错误.我想返回类似于OAuthAuthorizationServerProvider返回的错误的自定义错误:{"error": "invalid_grant","error_description": "You have 3 more attempts before Your account will be locked." }在我的ApiController里面我添加了这个方法:public IHttpActionResult Test() {HttpError err = new HttpError();err["error"] = "400...

c# – 无法访问Newtonsoft.Json.Linq.JValue上的子值【代码】

我正在使用WinForms(C#)来查找Google和Bing中的排名和关键字位置.为此,我使用的是Newtonsoft.Json.Net2.0.dll.当我正在运行该过程时,它显示错误:Cannot access child value on Newtonsoft.Json.Linq.JValue.我怎么解决这个问题?public class GoogleSearch {public int Search(string siteUrl, string searchExpression, ref string stage){int position = 100;const string urlTemplate = @"http://ajax.googleapis.com/ajax/ser...

c# – 执行后台操作时无法访问AbortButton【代码】

我的要求是需要在alertbox中点击中止按钮时中止后台工作操作(附图像Export).因为GetData()将花费更多时间来执行. 如果调用Dowork方法,则不需要访问UI元素,这意味着我们需要限制它直到后台工作者完成.所以我放了Application.Current.Dispatcher.如果我删除(Application.current.dispatcher)行,我们可以访问UI元素并执行一些操作,但我们需要在执行dowork事件时限制它. 任何解决方案,try{var backGroundWorker = new CancelSupportedB...

c# – 软键盘重叠TextBoxes并使它们无法访问【代码】

当输入字段与软键盘重叠时,如何在ScrollViewer中到达输入字段? 这种情况很容易复制: >使用包含一些TextBox的ScrollViewer创建一个新页面.根据需要制作尽可能多的TextBox,直到需要滚动页面以到达最后三个TextBox.<ScrollViewer><StackPanel Orientation="Vertical"><TextBox Margin="20" /><TextBox Margin="20" /><TextBox Margin="20" />..<TextBox Margin="20" /><TextBox Margin="20" /><TextBox Margin="20" PlaceholderText...

在UserManager.ResetPasswordAsync上c# – ‘无法访问已处置对象’错误【代码】

执行userManager.ResetPasswordAsync时出现以下错误:An unhandled exception occurred while processing the request.ObjectDisposedException: Cannot access a disposed object. Object name: 'TestDb'. Microsoft.Data.Entity.DbContext.get_ServiceProvider()我简化了代码,以便更容易阅读.我在控制器生命周期中调用了userManager两次.一旦生成令牌,一次用于重置密码:private readonly UserManager<ApplicationUser> userMana...

c# – BackgroundWorker – 调用线程无法访问对象【代码】

所以在我的DoWork中,我有List<KeyValuePair<String, BitmapImage>> Files = new List<KeyValuePair<string,BitmapImage>>((List<KeyValuePair<String, BitmapImage>>)e.Argument);foreach (KeyValuePair<String, BitmapImage> i in Files) {string temp = i.ToString(); .......(1)//..... }我将论点传递如下: – backgroundWorkerForReupload.RunWorkerAsync(files);其中“files”属于Type List< KeyValuePair< st...

…由于其保护级别为c#/ asp.net而无法访问【代码】

我有一个单独的类的应用程序,我在代码隐藏文件(在Page_Load中)实例化.在类中有一些我希望能够从代码隐藏文件调用的方法,但由于某种原因它不起作用(SecretNumber.MakeGuess(int)由于它的保护级别而无法访问).这个班级和方法是公开的,那么原因是什么呢? // Default.asx.cs...protected void btnCheckNr_Click(object sender, EventArgs e) {if (!Page.IsValid){return;}else{var guessedNr = int.Parse(inputBox.Text);var result =...

c# – 无法访问已处置的对象 – wcf客户端【代码】

我有一个WCF客户端,我遇到了问题.我不时会收到此异常:无法访问已处置的对象.这就是我打开连接的方式:private static LeverateCrmServiceClient crm = null;public static CrmServiceClient Get(string crmCertificateName){if (crm != null){crm.Close();}try {crm = new LeverateCrmServiceClient("CrmServiceEndpoint");crm.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine,StoreName.My,X509...

c# – 为什么我的foreach中的代码无法访问? (已经过单元测试的工作代码的确切副本)【代码】

下面的代码是一个完美的代码的精确副本.不同之处在于此代码放在WCF服务应用程序项目中,而工作代码来自Windows窗体应用程序项目. foreach中的代码是无法访问的,这很奇怪,因为我之前测试过代码并且它有效,返回正确的值public IEnumerable<Employee> GetStudentDetails(string username,string password){var emp = agrDb.LoginAuthentication(username, password);//procedure in the database thats returning two values//Namely: ...