Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all 8156 articles
Browse latest View live

How to set .net framework trust level to Low for C#.net application

$
0
0
I have a C# app running in fully trusted zone "My computer". I have checked trust level of application under "Microsoft .net Framework configuration tool" and it is showing as "unrestricted" which means fully trusted.  Now I want to set this trust level to low for application. How can I achieve this ? It would be better if this can be achieved without code changes of application. Can we mention these settings in config file of application ?  Assembly is not signed.
I have tried to modify trust level from "Microsoft .net Framework configuration tool -> Runtime Security Policy -> Trust assembly"  but getting error message as "Hash for the assembly cannot be generated".
I think this error because of my assembly is not signed.
Can we have a application with trust level set to low, running in zone with trust level as Fully trusted.  

Thanks,
Sagar

Set Physical Hard Disk Online Offline

$
0
0

Hi All,

i have a problem here where when i detected hard disk is going to fail soon using WMI, i would like to make the hard disk to be set as offline. May i know how can i access to get the hard disk online/offline status and how do i set the hard disk to be online and offline?

regards,

Joh

"Polymorphic array"

$
0
0

Assume I have an array of bytes (C#): byte[] bytes = new byte[100];
I want to expose part of the array for access and found IList/ArraySegment<byte> to be quite convenient, e.g:
IList<byte> byteList = new ArraySegment<byte>(bytes, 10, 10);
This works fine, changing a byte in the byteList by e.g.: byteList[2] = 3 reflects the change into the underlying array.
Now I want to expose the same (or similar) segment of the original array (byte[]) as IList<ushort> instead, like e.g.:
IList<ushort> wordlist = new ArraySegment<ushort>(bytes, 10, 5); // Note half the count compared to the byteList

This doesn't work, is this or something similar possible to do (without copying due to performance) ?
The idea is of course that 1 pcs ushort spans 2 pcs bytes.

help. asp.net with vb bug

$
0
0

This is a bug sometimes pops up. Can you help me to fixed this very urgent guys.

System.IndexOutOfRangeException: Index was outside the bounds of the array.
at OrdersDistributionReportOpener.GenerateCareInstructionReport() in *.aspx.vb:line 351
at OrdersDistributionReportOpener.Page_Load(Object sender, EventArgs e) in *.aspx.vb:line 26
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Exception of type 'System.Web.HttpUnhandledException' was thrown.

at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.orders_ordersdistributionreportopener_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Asp.net Identity password hashing algorithm

$
0
0

In the new membership system what hashing algorithm is used for password hashing? can't find it in the documentation

Designer workflow with more than one lists involved

$
0
0

I want to create a designer workflow which takes the values mfrom two lists.

If it is possible, could you please help me with a link.

Tnx

MEF2 RegistrationBuilder.ForTypesMatching not exporting the parts after updating the system with KB2840642v2

$
0
0

We are using MEF2 RegistrationBuilder.ForTypesMatching for exporting the types from the class library. I have attached the sample code below. This is working fine before updating the system with the Microsoft update KB2840642v2. But is not exporting any parts after updated the system with  the update KB2840642v2. One thing we noticed is that it is not working when I put this code in Global.asax.cs. But the code is working fine on a console application. The same issue is there on .net 4.5 and .net 4.5.1. Tested the same result on Visual Studio 2012 and Visual Studio 2013.

Looking for a fix or workaround for this.

using HandlerModule;
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Registration;
using System.Reflection;
using System.Web.Hosting;

namespace WebApplication1
{
    public class Global : System.Web.HttpApplication
    {
        private const string TaskServices = "HandlerModule.dll";

        protected void Application_Start(object sender, EventArgs e)
        {

            var reg = new RegistrationBuilder();

            string path = HostingEnvironment.MapPath("~/bin");

            AggregateCatalog mAggrCatalog = new AggregateCatalog();

            mAggrCatalog.Catalogs.Add(new DirectoryCatalog(path, TaskServices, reg));


            reg.ForTypesMatching(t => IsDescendentOf(t, typeof(IRequestHandler<,>)))
                        .Export(builder => builder.AsContractType(typeof(IRequestHandler<,>)));


            //context.ForTypesMatching(t => t.GetInterface(typeof(IRequestHandler<,>).Name) != null)
            //            .ExportInterfaces());


            var container = new CompositionContainer(mAggrCatalog, CompositionOptions.DisableSilentRejection);

            container.ComposeExportedValue(mAggrCatalog);
        }

        private static bool IsGenericDescendentOf(TypeInfo openType, TypeInfo baseType)
        {
            if (openType.BaseType == null)
            {
                return false;
            }
            if (openType.BaseType == baseType.AsType())
            {
                return true;
            }
            foreach (Type type in openType.ImplementedInterfaces)
            {
                if (type.IsConstructedGenericType && (type.GetGenericTypeDefinition() == baseType.AsType()))
                {
                    return true;
                }
            }
            return IsGenericDescendentOf(IntrospectionExtensions.GetTypeInfo(openType.BaseType), baseType);
        }

        private static bool IsDescendentOf(Type type, Type baseType)
        {
            if (((type == baseType) || (type == typeof(object))) || (type == null))
            {
                return false;
            }
            TypeInfo typeInfo = IntrospectionExtensions.GetTypeInfo(type);
            TypeInfo info2 = IntrospectionExtensions.GetTypeInfo(baseType);
            if (typeInfo.IsGenericTypeDefinition)
            {
                return IsGenericDescendentOf(typeInfo, info2);
            }
            return info2.IsAssignableFrom(typeInfo);
        }
    }
}

#The classes I'm exporting are on the HandlerModule class library project. Code below

namespace HandlerModule
{
    public interface IRequestHandler<TRequest, TResponse>
    {
        TResponse Handle(TRequest request);
    }
}

namespace HandlerModule
{
    public class GetOrderRequestHandler<TRequest, TResponse> : IRequestHandler<TRequest, TResponse>
        where TRequest: class
        where TResponse: class
    {

        public GetOrderRequestHandler()
        {
        }

        public TResponse Handle(TRequest pRequest)
        {
                return "MyREsponse" as TResponse;
        }
    }
}

Attempted to read or write protected memory on any SQL connection open after installing .Net Framework 4.5.1 (ADO.NET)

$
0
0

Hi, ive installed VS2013 RTM lately and discovered that all SQL connects stopped working. They all die with the exception below. All means any program that opens an SQL connection via ADO.NET dies. This includes SQL Managment Studio, Visual Studio or any other program. 

To track it down ive created an application with the following code which reproduces that error on "con.Open".

var con = new SqlConnection("Server=Server;Database=Foobar;User=Foobar");
con.Open();

So Ive uninstalled all which have todo with SQL or Dotnet.

Ive installed .Net 4.0 - works
Ive installed .Net 4.5 - works
Ive installed .Net 4.5.1 - error

My configuration is Windows 7 Enterprise 64bit. Everything other then SQL connection, works fine. Even complex .Net applications working when they dont use SQL connections.

I have absolutely no idea how to fix that, so please give me a hint!

Full error stacktrace of the app above:

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Data.SqlClient.SNIHandle.ReleaseHandle()
   at System.Runtime.InteropServices.SafeHandle.InternalDispose()
   at System.Data.SqlClient.TdsParserStateObject.Dispose()
   at System.Data.SqlClient.TdsParser.Disconnect()
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginFailure()
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, Stri
ng newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, O
bject providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData r
econnectSessionData)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConn
ectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConne
ctionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection
)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean o
nlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbCon
nectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions
, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletio
nSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()


Elements of .net language.

$
0
0
Anyone please could you inform me about Indexes Attributes.

How to drow a chart

$
0
0

Hello to everybody!

I need to draw a chart similar to a flow chart, starting from a structured xml file containing the informations I have to draw. It whould be great (but it also can be a successive target) if it was possible to modify the chart and the modifications go back to the xml. An example of the result I'd need:

Xml file:

<chart>

<node1>

    <node2/>

</node1>

<node3>

    <node4/>

    <node5/>

</node3>

</chart>

Result:

-----------                                   -----------

| node1  | --------------------------| node3  |

-----------                                   -----------

  |                                                 |

  |   -----------                                |   ----------

  |_ | node2  |                                |_| node4  |

      -----------                                |   ----------

                                                    |

                                                    |  ----------

                                                    |_ | node5  |

                                                       -----------

I also need to write some infotmations on each node.

Does exist some graphical library in .net or eventually outside the .net framework that can help me in drowing this chart? What is the best approach to aim this target?

Thanks in advance,

Paolo


Paolo

vc++

$
0
0
Versions – Message Maps – Document/View Architecture.

WindowsAutomation fails when there is no open session

$
0
0


I wrote an automation program which automates another GUI application using the WindowsAutomation feature in .NET 4.0. I do not know the exact technical terms to describe this situation, but ...  it works fine if the programs are actually visible (i.e., I logged in on a real machine, or a remote desktop session is kept open) but it fails if they are not visible (for example, there are two users: A and B, and the programs are running on user A's session, and currently user B is using the computer on the monitor.)

Is this a common problem, or just the behaviour of the particular application I am automating?

.NET Framework Error

$
0
0

I am trying to use a program and everytime I launch the program, I get this error:

http://icap.me/i/hFHZPWfIBi.png

Is there anything I can do to fix this? I have already tried uninstalling and re-installing .NET Framework and downloading the latest version.

Windows Service Started Stage

$
0
0

Hi,

i've develop a service which is using a method which is using wait event on start. However, when i start the service, it would not get started because the wait for next event is not triggered unless i triggered it manually. May i know if i can call the method after the service is started?

            watcher.Start();
            watcher.WaitForNextEvent();

regards,

Joh

WIF Passive HTML form allowing caching

$
0
0

When using the FederatedPassiveSecurityTokenServiceOperations class from within our custom STS (ASP.NET MVC 4 site), the ProcessRequest() method correctly handles the incoming WS-FED login and spits out the passive HTML form that auto-POST's to the relying party. However, it seems that the Cache-Control header of this form is set to "Private", which is allowing browsers to cache this bootstrap form. In short, after logging out, if you click the "back" button enough times to land on that form again, it will indeed auto-POST and instantiate a new session with the RP.

We've noticed we can set the Cache-Control header _before_ calling this method to declare no-cache/no-store, but it seems that due to the nature of the content the framework should either a) be doing this automatically, or b) allow it to be specified.

Bug or feature?


Unable to refer Microsoft.Experimental.IO from VB 6.0 project

$
0
0

Hello Everyone,

I have dll called Microsoft.Experimental.IO for handling Long File path. It is working in .net 4.0 application.

But When I tried to refer the same dll on VB 6.0 application, it is not working.

I would like to call a method from Microsoft.Experimental.IO dll into my vb 6.0 project.

Please help me to resolve this issue.

Thanks,

Sathiya Jeba.

Assembly.LoadFrom only locking file when Server on a Domain

$
0
0

I am running into the dreaded Assembly.loadfrom file locking error.  But only when our server is added to our test domain.  If we remove it and put in just in a workgroup, we do not find this behavior.

Please help.?

MemoryCache custom ChangeMonitor

$
0
0

I couldn't find any good examples of how to use ChangeMonitor classes.

Here's my problem: I'm caching a few method of my Repository, building a key to uniquely identify the cached data. The cached data has a expiration time, but the data can change before the expiration takes place.

Take a look:

 public class CachedUserRepository : CachedRepositoryBase, IUserRepository
    {
        private readonly CacheKeyBuilder keyBuilder;
        private readonly IUserRepository repository;
        private readonly CacheManager cacheManager;

        public CachedUserRepository(IUserRepository repository)
        {
            this.repository = repository;
            keyBuilder = new CacheKeyBuilder();
            cacheManager = CacheManager.Instance;
        }

        public IEnumerable<Content> GetWatchList(User user, Size cover = null, Pagination pagination = null)
        {
            var key = keyBuilder.Create(GetType()).With(user, cover, pagination).Build();
            var entry = cacheManager.Get(key);
            if (entry != null)
                return (IEnumerable<Content>)entry;

            var result = repository.GetWatchList(user, cover, pagination);
            cacheManager.Add(user, key, result, Duration(CacheType.VeryLow));

            return result;
        }

I'm caching the WatchList of the users. It's a web app and there could be several users, so I'm building a key for each one of them. That's fine. However, my repository has the following method as well:

public void AddBookmark(User user, Identifier contentId)
        {
            repository.AddBookmark(user, contentId);
        }

When the following method is called, I need to clear any cached data of the given user (method's parameter). How to accomplish that? ChangeMonitor is the way? And if it is, how can I write the code for it?


Take a look at WPF FlashMessage
About.me

querying and get distinct from a datatable

$
0
0

Hi list,

I have a datatable which I need to get some details from. The dt has an integer type column "mycolumn", which has data of -1 or other positive number. Now all I want to do is to take only those rows with positive figures, then count number of distinct one. For example if I got: -1, 2, -1, 3, 2, 3, -1, -1, 2, 3, I need to get 2, which means there are only two numbers which are not -1.

String Q= “where mycolumn<>-1“

Int n= elt.select(Q).count(r => r.field<int>(“eltrow“));

first I got this error: "Cannot implicitly convert type int to bool" , then do now know how to finish the code even if I fix the error.

would you please help me on this?

thanks

Arvin


how do i close a message box programaticlly in c#

$
0
0
i want to close a messagebox in c# after a certain period of time how do i do it in c#
Viewing all 8156 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>