小编Jar*_*Par的帖子

如何防止我的.Net dll被添加为参考?

假设我写了一个.Net dll,并想用我的应用程序分发它.如何通过向自己的应用程序添加对此dll的引用来阻止任何具有精明的用户安装VS的副本?

.net security dll visual-studio

4
推荐指数
2
解决办法
1560
查看次数

C#通用接口

我需要将泛型类型参数传递给接口.我有一个名称类型的字符串.

我有这样的事情:

string type = "ClassType";
Type t = Type.GetType("ClassType");

IProvider<t> provider = (IProvider<t>)someObject;
Run Code Online (Sandbox Code Playgroud)

这对我不起作用.这样做的正确方法是什么?谢谢.

c# generics reflection

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

在Visual Studio 2008中创建.exe

任何人都可以善良,并告诉我如何在visual studio 2008中为基于win32控制台的c ++程序制作一个exe文件?谢谢

c++ visual-studio-2008 visual-studio

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

为什么.Equals在这个LINQ示例中不起作用?

为什么这会产生空集?

Object[] types = {23, 234, "hello", "test", true, 23};

var newTypes = types.Select(x => x.GetType().Name)
    .Where(x => x.GetType().Name.Equals("Int32"))
    .OrderBy(x => x);

newTypes.Dump();
Run Code Online (Sandbox Code Playgroud)

c# linq linqpad

4
推荐指数
3
解决办法
1952
查看次数

变量占用某个值时的断点

我有类似于以下代码的东西......

void function(int x)
{
    // complicated operation on x
    blah 
    blah
}
Run Code Online (Sandbox Code Playgroud)

这一切看起来都很好,除非x恰好是一个特定的值,比如"273".但x为273是一种罕见的事件,99.999%的时间是其他值.现在我希望观察使用x = 273调用此函数时的事件,所以我想插入一个仅受x命中的断点就是该值.也许我可以这样做:

void function(int x)
{
    if (x == 273)
    {
        // put breakpoint on this line.
    }
    // complicated operation on x
    blah 
    blah
}
Run Code Online (Sandbox Code Playgroud)

问题是,编译器可能会优化掉这个"if"语句,因为它没有做任何事情.所以我的问题是我应该在"if"语句中放置什么以确保它被编译成某种东西......或者我应该以某种完全不同的方式跟踪x == 273的情况.

c debugging visual-studio-2008 visual-studio

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

为什么这个锁定语句不起作用?

为什么这个锁定测试不起作用?它正在抛出一个异常的控制台.Write该集合被修改了....

    static List<string> staticVar = new List<string>();

    static void Main(string[] args)
    {
        Action<IEnumerable<int>> assyncMethod = enumerator =>
                {
                    lock (staticVar)
                        foreach (int item in enumerator)
                            staticVar.Add(item.ToString());


                };

        assyncMethod.BeginInvoke(Enumerable.Range(0, 500000), null, null);
        Thread.Sleep(100);

        Console.Write(staticVar.Count());
        foreach (string item in staticVar)
        {

        }
    }
Run Code Online (Sandbox Code Playgroud)

c# multithreading locking

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

linq group by with count

我试图在linq中编写查询

Select UserId, UserNumber 
FROM User
where UserNumber in
(Select UserNumber
        FROM User
        group by UserNumber
        having Count(UserId) = 1)
Run Code Online (Sandbox Code Playgroud)

阿比提示?

linq

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

来自C#dll的扩展方法在VB.NET中不能作为扩展

实际上我不知道他们是否应该工作

我在C#中创建了一个库,人们告诉我,我的一种方法在VB.NET中不能作为扩展名 http://valueinjecter.codeplex.com/Thread/View.aspx?ThreadId=227498

这是方法:

public static PropertyDescriptorCollection GetProps(this object o)
{
   return GetProps(o.GetType());
}
Run Code Online (Sandbox Code Playgroud)

.net c# vb.net extension-methods

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

Winforms .Net应用程序无法启动

我有一个在大多数机器上运行的标准winforms应用程序.在安装了.Net 4(完整版)的2003服务器上,它无法运行.

事件查看器显示:

Event Type: Error
Event Source:   .NET Runtime
Event Category: None
Event ID:   1026
Date:       4/01/2012
Time:       10:07:37 AM
User:       N/A
Computer:   DRACO
Description:
Application: start.exe
Framework Version: v4.0.30319

Description: The process was terminated due to an unhandled exception.
Exception 
Info: System.TypeInitializationException
Stack:
   at BootStrap.Program.Main(System.String[])

Event Type: Error
Event Source:   .NET Runtime 4.0 Error Reporting
Event Category: None
Event ID:   1000
Date:       4/01/2012
Time:       10:07:34 AM
User:       N/A
Computer:   DRACO
Description:
Faulting application start.exe, version 1.0.4386.17553, stamp 4f0384f3, …
Run Code Online (Sandbox Code Playgroud)

.net c# winforms

4
推荐指数
2
解决办法
4734
查看次数

如何在Visual Studio中恢复参数文档弹出窗口?

参数文档弹出示例

只要您键入方法调用的左括号,就会自动显示此参数文档弹出窗口.

请注意,弹出窗口显示特定于当前参数的文档.

每当您在参数之间键入逗号时,弹出窗口也会显示.

所以,当我想要文档时,我通常擦除并重新键入我想要doc的参数之前的逗号.我已经做了多年,但我现在意识到可能有更好的方法来做到这一点(阅读:快捷键).

因此我的问题是:你如何带回参数文档弹出窗口?

intellisense keyboard-shortcuts visual-studio-2010 visual-studio

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