我遇到了此留言板帖子中描述的问题.
我有一个托管在自己的AppDomain中的对象.
public class MyObject : MarshalByRefObject
{
public event EventHandler TheEvent;
...
...
}
Run Code Online (Sandbox Code Playgroud)
我想为该事件添加一个处理程序.处理程序将在不同的AppDomain中运行.我的理解是这一切都很好,事件通过.NET Remoting神奇地传递到这个边界.
但是,当我这样做时:
// instance is an instance of an object that runs in a separate AppDomain
instance.TheEvent += this.Handler ;
Run Code Online (Sandbox Code Playgroud)
...它编译得很好,但在运行时失败:
System.Runtime.Remoting.RemotingException:
Remoting cannot find field 'TheEvent' on type 'MyObject'.
Run Code Online (Sandbox Code Playgroud)
为什么?
编辑:演示问题的工作应用程序的源代码:
// EventAcrossAppDomain.cs
// ------------------------------------------------------------------
//
// demonstrate an exception that occurs when trying to use events across AppDomains.
//
// The exception is:
// System.Runtime.Remoting.RemotingException:
// Remoting cannot find …Run Code Online (Sandbox Code Playgroud) 当属性包含多个单词时,我在按属性选择节点时遇到问题.例如:
<div class="atag btag" />
Run Code Online (Sandbox Code Playgroud)
这是我的xpath表达式:
//*[@class='atag']
表达式适用于
<div class="atag" />
但不是前一个例子.我该如何选择<div>?
我需要编写一个自定义批处理文件重命名器.我已经完成了大部分工作,除了我无法弄清楚如何检查文件是否已经打开.我只是使用该java.io.File包,并且有一个canWrite()方法,但似乎不测试该文件是否被另一个程序使用.关于如何使这项工作的任何想法?
是否可以在静态上下文中重载C++类操作符?例如
class Class_1{ ... }
int main()
{
Class_1[val]...
}
Run Code Online (Sandbox Code Playgroud) 根据下面的代码,我用于常规的mysql,我怎么能将它转换为使用mysqli?
是否像更改**mysql _query($ sql)一样简单 ; 到mysqli _query($ sql) ; ?**
<?PHP
//in my header file that is included on every page I have this
$DB["dbName"] = "emails";
$DB["host"] = "localhost";
$DB["user"] = "root";
$DB["pass"] = "";
$link = mysql_connect($DB['host'], $DB['user'], $DB['pass']) or die("<center>An Internal Error has Occured. Please report following error to the webmaster.<br><br>".mysql_error()."'</center>");
mysql_select_db($DB['dbName']);
// end header connection part
// function from a functions file that I run a mysql query through in any page.
function executeQuery($sql) { …Run Code Online (Sandbox Code Playgroud) 我想将我的浮点字段转换为十进制字段; 我希望在我的十进制字段中精度为11,2但是当我尝试更改我的字段类型时(例如:Amount)我得到一个错误:"算术溢出错误将float转换为数据类型numeric.语句已被终止".我的字段在表中是十进制(11,2),我的最大值和最小值是:1,603,837,393.70 < - > -1,688,000,000.00(金额).
我创建了一个临时表来取出数据并更改了我的字段的结构,并且工作正常但现在我需要将数据放回去(临时表仍然具有原始浮点字段),而我只是简单地无法使其插入带有insert select语句的值.
由于我的值不超过我的类型的范围,我想知道为什么甚至不可能在这样的select语句上强制转换:
select Id,AccountId, cast(Amount as decimal(12,2)) as Amount,
cast(AmountB as decimal(12,2)) as AmountB
FROM myTable
Run Code Online (Sandbox Code Playgroud)
我无法确定不转换我的领域的原因.
希望有人可以指出我正确的方向.我正在尝试在Eclipse中创建一个CellEditor,当我点击该字段时,我得到一个Unhandled事件循环异常,下面是堆栈跟踪.
此列的单元格编辑器代码如下所示
/** Cell Editor Row 2 **/
textEditor = new TextCellEditor(table);
((Text)textEditor.getControl()).setTextLimit(10);
editors[1] = textEditor;
org.eclipse.core.runtime.AssertionFailedException: assertion failed:
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:111)
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:97)
at org.eclipse.jface.viewers.TextCellEditor.doSetValue(TextCellEditor.java:228)
at org.eclipse.jface.viewers.CellEditor.setValue(CellEditor.java:855)
at org.eclipse.jface.viewers.EditingSupport.initializeCellEditorValue(EditingSupport.java:96)
at org.eclipse.jface.viewers.ColumnViewerEditor.activateCellEditor(ColumnViewerEditor.java:194)
at org.eclipse.jface.viewers.ColumnViewerEditor.handleEditorActivationEvent(ColumnViewerEditor.java:443)
at org.eclipse.jface.viewers.ColumnViewer.triggerEditorActivationEvent(ColumnViewer.java:680)
at org.eclipse.jface.viewers.ColumnViewer.handleMouseDown(ColumnViewer.java:664)
at org.eclipse.jface.viewers.ColumnViewer.access$0(ColumnViewer.java:660)
at org.eclipse.jface.viewers.ColumnViewer$1.mouseDown(ColumnViewer.java:89)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:179)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.tasc.swb.internal.application.SWBApplication.start(SWBApplication.java:414)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) …Run Code Online (Sandbox Code Playgroud) 假设我有一个这样的字符串:'12,423,343.93'.如何将其转换为float简单,有效和优雅的方式?
我似乎需要从字符串中删除多余的逗号,然后调用float(),但我没有很好的解决方案.
谢谢
我想加载ASPNET运行时,运行一个或多个页面,然后卸载它.这是出于测试目的.这不是UI测试; 我真的只是在ASPNET上下文中测试库的使用.
通常这种事情是通过调用来完成的System.Web.Hosting.ApplicationHost.CreateApplicationHost.
这就是我目前的方式:
public class Manager : System.MarshalByRefObject
{
private void HostedDomainHasBeenUnloaded(object source, System.EventArgs e)
{
aspNetHostIsUnloaded.Set();
}
private ManualResetEvent aspNetHostIsUnloaded;
public void Run(string[] pages)
{
bool cleanBin = false;
MyAspNetHost host = null;
try
{
if (!Directory.Exists("bin"))
{
cleanBin = true;
Directory.CreateDirectory("bin");
}
var a = System.Reflection.Assembly.GetExecutingAssembly();
string destfile= Path.Combine("bin", Path.GetFileName(a.Location));
File.Copy(a.Location, destfile, true);
host =
(MyAspNetHost) System.Web.Hosting.ApplicationHost.CreateApplicationHost
( typeof(MyAspNetHost),
"/foo", // virtual dir
System.IO.Directory.GetCurrentDirectory() // physical dir
);
aspNetHostIsUnloaded = new ManualResetEvent(false);
host.GetAppDomain().DomainUnload += this.HostedDomainHasBeenUnloaded; …Run Code Online (Sandbox Code Playgroud) 我无法找出问题所在,以及为什么我一直在Internet Explorer 8中收到此错误,因为这是我收到的唯一错误.有什么想法,或简单的解决方案?我没有注意到我的代码有任何问题,这只是让我烦恼的消息.
网页错误详情.
用户代理:Mozilla/4.0(兼容; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)时间戳:2009年9月7日星期一19: 11:13 UTC
Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
Line: 0
Char: 0
Code: 0
Run Code Online (Sandbox Code Playgroud)