小编Sco*_*hic的帖子

在不同的AppDomain中加载/卸载程序集

我需要在运行时加载的程序集中执行一个方法.现在我想在方法调用后卸载那些已加载的程序集.我知道我需要一个新的AppDomain,所以我可以卸载库.但在这里,出现了问题.

要加载的程序集是我的插件框架中的插件.他们根本没有切入点.我所知道的是它们包含一些实现给定接口的类型.旧的非AppDomain代码看起来像这样(稍微缩短):

try
{
    string path = Path.GetFullPath("C:\library.dll");
    AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
    Assembly asm = Assembly.LoadFrom(path);
    Type[] types = asm.GetExportedTypes();
    foreach (Type t in types)
    {
        if ((t.GetInterface("IStarter") != null) && !t.IsAbstract)
        {
            object tempObj = Activator.CreateInstance(t);
            MethodInfo info = t.GetMethod("GetParameters");
            if (info != null)
            {
                return info.Invoke(tempObj, null) as string;
            }
        }
    }
}
catch (Exception ex)
{
    MessageBox.Show(String.Format("Damn '{0}'.", ex.Message), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
    if (args.Name.StartsWith("MyProject.View,"))
    {
        string path = Path.GetFullPath("C:\view.dll"));
        return …
Run Code Online (Sandbox Code Playgroud)

c# reflection mmc appdomain

22
推荐指数
1
解决办法
3万
查看次数

Android无法打开keycharmap文件

我是Android Developement的新手.我正在创建简单的文本到语音语音应用程序,这里我得到错误.我在下面提到过.任何人都可以帮忙....

03-20 11:49:30.460  24666-24666/com.example.test.app W/KeyCharacterMap? Can't open keycharmap file
03-20 11:49:30.460  24666-24666/com.example.test.app W/KeyCharacterMap? Error loading keycharmap file
03-20 11:49:30.460  24666-24666/com.example.test.app W/KeyCharacterMap? Using default keymap 
Run Code Online (Sandbox Code Playgroud)

代码:

package com.example.test.app;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.app.Activity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;

import java.util.Locale;

public class MainActivity extends Activity implements TextToSpeech.OnInitListener{

    private TextToSpeech speech;
    private ImageButton speak;
    private EditText comments;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main); …
Run Code Online (Sandbox Code Playgroud)

android android-intent android-layout android-fragments

20
推荐指数
0
解决办法
3891
查看次数

在VS2008中发布网站后无法解析全局资源

我有一个在VS 2008中运行的Web项目.我们在App_GlobalResources文件夹中有一些全局资源文件(*.resx)用于国际化.所有这些就像我在VS上安装本地IIS时的魅力一样.

但是当我将我的web项目发布到本地文件系统和/或其他服务器时,无法再找到所有资源.所以我想预编译会以某种方式腐蚀东西.当我调用预编译的Web时,我得到一个错误,即无法找到具有密钥xyz的资源对象,尽管之前可以找到它.

我检查了.NET反射器,如果资源的东西进入*.dlls.所有这些标识符都在那里(bin/Web.dll,bin/<culture> /Web.resources.dll).标识符的加载方式如下:

<asp:MenuItem NavigateUrl="~/OrderNew.aspx" Text="<%$ Resources:MyProject, MenuNewOrder %>" Value="NewOrder">
Run Code Online (Sandbox Code Playgroud)

资源文件名为MyProject.resx和MyProject.<culture> .resx其中<culture>对应于特定文化(即MyProject.de-DE.resx).

任何想法如何解决这个问题?

我非常感谢任何帮助.

谢谢

编辑:

如果我手动将App_GlobalResources文件夹复制到输出,则可以正常加载资源.所以我真的很想知道这个预编译是什么.

我仍然有兴趣以"正确的方式"解决问题.

asp.net resources publishing pre-compilation visual-studio-2008

13
推荐指数
1
解决办法
1万
查看次数

收集 Windows 服务依赖项

我最近编写了一个 Windows 服务并将其安装在生产系统上。应用一些 Windows 更新后,服务器必须重新启动,并且我的服务无法正确加载,尽管它被设置为自动启动。在客户注意到故障后,手动服务开始正常。经过一番研究,我发现我错过了向我们的服务添加服务依赖项。因此,对于我们的案例来说,服务的启动顺序是错误的。

我可以解决这个问题,但我现在对如何收集所有必要的服务依赖项的工具或过程非常感兴趣。你知道有一段代码可以处理这个问题吗?

我很感激任何提示。

dependencies windows-services

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

我想从用户获取所请求的整数数并将它们存储到数组中

我已经要求用户输入金额,但我正在努力将它们存储到一个数组中.这是我到目前为止所做的.请帮助.我是初学者.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int intNum;

            Console.WriteLine("How many integers must be stored in the program?");
            intNum = Convert.ToInt32(Console.ReadLine());

        }

    }
}
Run Code Online (Sandbox Code Playgroud)

c# arrays

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

使用c#写入XML

如何使用c#创建具有此格式的xml文件?

<?xml version="1.0" encoding="utf-8" ?>
<wrap>
  <content>
    <title>
      WHAT ARE ROLES?
    </title>
    <text>
        Roles are security based permissions that can be assigned to registered user of the site. Users can have any number of role based security permissions that the administrator deems appropriate. Certain parts of the application may have security permissions assigned to them to make the information they contain available only to those users with the required permisions.
    </text>
  </content>
  <content>
    <title>
      CREATE A ROLE
    </title>
    <text>
        To …
Run Code Online (Sandbox Code Playgroud)

c# xml

0
推荐指数
1
解决办法
296
查看次数

XSL转换没有采用xml

我正在尝试使用XSL样式表转换XML字符串.但出于某种原因,他只接受我的根元素,而不是其余部分.有些东西可以摇摆不定的wimey probs,但我看不出这个问题..

我将在下面附上我的代码.

XSL

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://foo.com/foo" xmlns:ns1="http://foo.com/foo" exclude-result-prefixes="ns1">
    <xsl:template match="/">
        <ns0:ProductionOrderRequests>
            <xsl:apply-templates select="ns1:ProductionOrderRequest" />
        </ns0:ProductionOrderRequests>
    </xsl:template>

    <xsl:template match="ns1:ProductionOrderRequest">
            <xsl:apply-templates select="ns1:ProductionOrderRequest" />
    </xsl:template>

    <xsl:template match="ns1:ProductionOrderRequest">
         <ProductionOrderRequest>
            <MESKey><xsl:value-of select="@MESKey" /></MESKey>
            <Material><xsl:value-of select="@Material" /></Material>
            <ProductionVersion><xsl:value-of select="@ProductionVersion" /></ProductionVersion>
            <Resource><xsl:value-of select="@Resource" /></Resource>
            <Plant><xsl:value-of select="@Plant" /></Plant>
            <OrderType><xsl:value-of select="@OrderType" /></OrderType>
            <StartDate><xsl:value-of select="@StartDate" /></StartDate>
            <StartTime><xsl:value-of select="@StartTime" /></StartTime>
            <EndDate></EndDate>
            <EndTime></EndTime>
            <TotalOrderQty><xsl:value-of select="@TotalOrderQty" /></TotalOrderQty>
         </ProductionOrderRequest>
    </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

要转换的XML

<?xml version="1.0" encoding="utf-8"?>
<ProductionOrderRequests xmlns:ns0="http://foo.com/foo">
    <ProductionOrderRequest>
        <MESKey>TblDatProduction_4017</MESKey>
        <Material>11596</Material>
        <ProductionVersion>0001</ProductionVersion>
        <Resource>60200001</Resource>
        <Plant>BE01</Plant>
        <OrderType>ZP76</OrderType>
        <StartDate>24-10-2008</StartDate>
        <StartTime>06:00:00</StartTime>
        <EndDate></EndDate>
        <EndTime></EndTime>
        <TotalOrderQty>1.00</TotalOrderQty> …
Run Code Online (Sandbox Code Playgroud)

c# xml xslt

0
推荐指数
1
解决办法
69
查看次数

Regext:十位数字,第四位数字不能是8或9

我怎样才能创建一个正则表达式

十位数,第四位不能是8位或9位?

任何帮助表示赞赏.

regex

-1
推荐指数
1
解决办法
40
查看次数