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

GetExportedValue cannot be called before prerequisite import has been set?

$
0
0

We are using MEF in a WPF application.

And we are getting this error:

GetExportedValue cannot be called before prerequisite import 'MyNamespace.MyMainClass..ctor (Parameter="myParameter", ContractName="IContractInterface")' has been set.

I am not using threads, I read sometimes this error happens with multiple threads, just in case, I created the composition container passing the "thread safe" parameter in true

var container =newCompositionContainer(catalog,true);

The Code I have is:

My simplified Main Class code is: (The idea is that if there are not import for IMySubClass, I will use a default Implementation, that is why I create it on the "OmImportsSatisfied" method and satisfy its imports.)

MyMainClass C#

[Export(typeof(IMyInterface)]publicclassMyMainClass:IPartImportsSatisfiedNotification,IMyInterface{[Import]publicIContainerContainer{ get;privateset;}[Import(AllowDefault=true)]publicIMySubClassMySubClass{ get;set;}[ImportingConstructor]publicMyMainClass([Import(AllowDefault=true)]IContractInterface myParameter=null):this(){if(myParameter!=null){//Do Something with myParameter}}publicvoidOnImportsSatisfied(){if(MySubClass==null){MySubClass=newMySubClass();Container.SatisfyImportsOnce(MySubClass);}//Some other stuff}

}

MySubClass C#

publicclassMySubClass:IPartImportsSatisfiedNotification,IMySubClass{[ImportMany]publicLazy<IMyAttributeInterface,IMyAttributeInterfaceMetadata>[]Exports{ get;set;}publicvoidOnImportsSatisfied(){foreach(var export inExports){var value = export.Value;//Here it throws the Exception//Do something.}}

The error is thrown in MySubClass, inside the OnImportSatisfied method on the line:

var value = export.Value;

However when I debug the ImportConstructor of MyMainClass is called successfully, andmyParameter is injected and used. Afterwards the OnImportsSatisfied method is calledand I get the error.


The Exports list from my Subclass comes from properties in other classes that have the Attribute "MyExportAttribute". I don't have much experience creating Export Attributes, so here is the code in case the problem is coming from it.

Export Attribute

publicinterfaceIMyAttributeInterfaceMetadata{stringProperty1{ get;}stringProperty2{ get;}}[MetadataAttribute][AttributeUsage(AttributeTargets.Field|AttributeTargets.Property|AttributeTargets.Class,AllowMultiple=false,Inherited=false)]publicclassMyExportAttribute:ExportAttribute,IMyAttributeInterfaceMetadata{stringProperty1{ get;}stringProperty2{ get;}publicMyExportAttribute(string property1,string property2):base(typeof(IMyAttributeInterface)){Property1= property1;Property2= property2;}}

Dzyann.-


How to deploy assembly 32 from installer 64 ?

$
0
0

Hi,

I have 2 assemblies 32 and 64. I want to put them in GAC folder in Deployment project target x64. I already put them in GAC folder. When I try to install, I got error 2908 and after click OK, it continue but throw error that it has no permission to access directory : [assembly-name]. Then the installation stop here can not continue.

The problem gone if I remove assembly 32 from GAC, so I think I might do wrong way to install assembly 32 together with 64 ?

So how to install assembly 32 and 64 together in deployment project target x64 ?


It's hard to be advanced programmer

Random 4 groups from one Group (Playing Cards Game)

$
0
0
Hi ,
I want to make playing cards game . I give every card a number from 1 to 52
now I need give cards to 4 players (every player has 13 cards) . so how I can make random 4 groups (every groups contain with 13 number ) and number from 1-52 and no group has the same number ?

I must Win

Retrieving the COM class factory for component with CLSID(00024500-0000-0000-C000-000000000046) failed due to the following error: 80040154

$
0
0

application type- C#, Web Application

COM component- Excel

reference added to bin folder:-Microsoft.Office.Interop.Excel

It is working on local environment but giving error in server environment.

Address array element and thread-safe

$
0
0

Hello!

I have red that access to different element of array is thread-safe, but to same is not.

But why this code work without any trouble?

            var array = new int[1];
            Parallel.For(0, 10000000, i => array[0] = i);

Unable to create file from Application_Start() event.

$
0
0

Hi,

(Sorry if this is in the wrong forum, but I couldn't find a better one.)

I have some code which attempts to create and write to a log file in a subdirectory of my website (shown below). If I put the first call to this code in the Page_Load() event of Default.aspx, it works fine every time. If, however, I make the first call to this code inside the Global.asax Application_Start() event, I get an access denied exception from .NET, even though the path displayed in the exception message is correct and is a subdirectory of my site root.

Has anyone encountered anything like this? It is as if the code running from Application_Start() has a more limited set of permissions than code running later.

Kind wishes ~ Patrick

string s = string.Format( "{0}logs\\Log.txt", HttpRuntime.AppDomainAppPath );
using( StreamWriter writer = new StreamWriter( s, true ) )
{
	string logEntry = DateTime.Now.ToString() + ": " + formattedMessage;
	writer.WriteLine( logEntry );
	writer.Flush();
}


POS for Net updates

$
0
0

So the last update to the pos for net installer was in 2008.

today we have .net 4.5 and pos for net is requiring the install of .net 2 and changes to application config files to work.

is anyone at Microsoft still working on POS for Net ?

is there any plan to release an update so that it works with .net 4 and not require the install of .net 2.0 ?

Reading Binary Format (QBasic) with C#

$
0
0

I have a binary file with data stored in an old format [Microsoft Binary Format (QBasic)]

The file is configured like this

-----------------------------------------------------
Start Byte | End Byte | Lenght | Description        |
-----------------------------------------------------
    0    |     3    |   4    | date format YYMMDD |
-----------------------------------------------------
    4    |     7    |   4    | Float              |
-----------------------------------------------------
    8    |     11   |   4    | Float              |
-----------------------------------------------------
  \
  \
  \
-----------------------------------------------------
   24    |     27   |   4    | Float              |
----------------------------------------------------- 

The first 4 bytes contain the date and reset all in Float like 34.5

When i read the file using BinaryRead i do not know to convert to date and float

Here is my code
========================================================


        FileStream fs;
        BinaryReader br;

        byte[] buffer = new byte[28];
        int intBuffer = 0;

fs = File.Open("myFile.dat", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
br = new BinaryReader(fs);

            while ((intBuffer = br.Read(buffer, 0, 28)) > 0)
            {
                DateTime date = GetDateOutOfByte(buffer, 0, 3);
                float f1 = GetFloatOutOfByte(buffer, 4, 7);
                float f2 = GetFloatOutOfByte(buffer, 8, 11);
                float f3 = GetFloatOutOfByte(buffer, 12, 15);
                float f4 = GetFloatOutOfByte(buffer, 16, 19);
                float f5 = GetFloatOutOfByte(buffer, 20, 23);
                float f6 = GetFloatOutOfByte(buffer, 24, 27);
            }

-----------------------------
private float GetFloatOutOfByte(byte[] buffer, int Start, int End)
        {
            string temp = "";
            float result =0.0F;
            for (int i = Start; i < End; i++)
            {
                temp += (char)bufferIdea;
            }
            // How to convert the temp to float?

            return result;
        }
------------------------------
private DateTime GetDateOutOfByte(byte[] buffer, int Start, int End)
        {
            string temp = "";
            DateTime result;
            for (int i = Start; i < End; i++)
            {
                temp += (char)bufferIdea;
            }
            // How to convert the temp to Date?

            return result;
        }
------------------------------

Any Help Please


 


Printing Directly to Printer

$
0
0

I have a client that has a process which builds a text file. This text file contains commands that is used by their thermal printer, i.e.:

^XA^CF,0,0,0^PR12^MD30^PW800%^PON
^FO0,147^GB800,4,4^FS
^FO0,401^GB800,4,4^FS
^FO0,746^GB800,4,4^FS
^FO35,12^AdN,0,0^FWN^FH^FDFrom:^FS
^FO35,31^AdN,0,0^FWN^FH^FDAri Rothman^FS
^FO35,51^AdN,0,0^FWN^FH^

They want this to print directly to their printer. I have attempted using the following code to produce the results:

publicclass Printer
{
[DllImport("winspool.Drv", EntryPoint="GetDefaultPrinter")]
publicstaticexternbool GetDefaultPrinter(
StringBuilder pszBuffer,
// printer name buffer
refint pcchBuffer // size of name buffer
);
[ DllImport( "winspool.drv",CharSet=CharSet.Unicode,ExactSpelling=
false,
CallingConvention=CallingConvention.StdCall )]
publicstaticexternlong OpenPrinter(string pPrinterName,
ref IntPtr phPrinter, int pDefault);
[ DllImport( "winspool.drv",CharSet=CharSet.Unicode,ExactSpelling=
false,
CallingConvention=CallingConvention.StdCall )]
publicstaticexternlong StartDocPrinter(IntPtr hPrinter,
int Level, ref DOCINFO pDocInfo);
[ DllImport( "winspool.drv",CharSet=CharSet.Unicode,ExactSpelling=
true,
CallingConvention=CallingConvention.StdCall)]
publicstaticexternlong StartPagePrinter(IntPtr hPrinter);
[ DllImport( "winspool.drv",CharSet=CharSet.Ansi,ExactSpelling=
true,
CallingConvention=CallingConvention.StdCall)]
publicstaticexternlong WritePrinter(IntPtr hPrinter,string data,
int buf,refint pcWritten);
[ DllImport( "winspool.drv" ,CharSet=CharSet.Unicode,ExactSpelling=
true,
CallingConvention=CallingConvention.StdCall)]
publicstaticexternlong EndPagePrinter(IntPtr hPrinter);
[ DllImport( "winspool.drv" ,CharSet=CharSet.Unicode,ExactSpelling=
true,
CallingConvention=CallingConvention.StdCall)]
publicstaticexternlong EndDocPrinter(IntPtr hPrinter);
[ DllImport( "winspool.drv",CharSet=CharSet.Unicode,ExactSpelling=
true,
CallingConvention=CallingConvention.StdCall )]
publicstaticexternlong ClosePrinter(IntPtr hPrinter);

public Printer()

{}

publicstaticvoid SendToPrinter(string jobName, string PCL5Commands, string printerName)

{

System.IntPtr lhPrinter=

new System.IntPtr();

DOCINFO di =

new DOCINFO();

int pcWritten=0;

di.pDocName=jobName;

di.pDataType="RAW";

OpenPrinter(printerName,

ref lhPrinter,0);

StartDocPrinter(lhPrinter,1,

ref di);

StartPagePrinter(lhPrinter);

WritePrinter(lhPrinter,PCL5Commands,PCL5Commands.Length,

ref pcWritten);

EndPagePrinter(lhPrinter);

EndDocPrinter(lhPrinter);

ClosePrinter(lhPrinter);

}

}

 

 

However, this prints the commands as text. But I am using an HP PCL 6 printer for testing purposes, so it may be caused by the printer not recognizing the commands. I am trying to gain opinions on this situation. Also, is there a more direct way to issue printer commands directly, or is this the best way? I was thinking maybe opening a socket between the client and the printer and feeding this through directly to the port.

 

Any thoughts?

Preventing function from being called using reflection

$
0
0

Hi

How can we prevent a function to be called using reflection ? From what i noticed is that event private function can be called using reflection, so is there anyway we can restrict even that ?

 

unable run a batch file using .net code at server

$
0
0

Hi,

while i execute solution to form an batch file in which psftp is called to pull files from server using .net code,

It works fine with my local machine. but at server nothing is happening.

Can anyone suggest related information.

Thanks in advance

Roles assignment to users

$
0
0
How many ways to assign roles to users?

markand

MessageBox.Show in .NET 4 versus .NET 2

$
0
0

I have an odd problem with .NET COM interop where MessageBox.Show doesn't display the message box if I am using .NET 4. It works fine with .NET 2 (I am changing the setting in the VS 2012 project I have).

Background:

I have a .NET class object that I expose to COM. I have a COM MFC windows application that calls CoCreateInstance and then calls a method on the .NET object as the app is starting up (splash screen has displayed but frame has not yet displayed). I can step thru the code of my COM app and see that CoCreateInstance succeeds and so does the call to the method. I cannot debug the .NET code from the .NET project directly as my breakpoints never trip (they are enabled) when I am using .NET 4. So I put a message box call into the method I call when the COM app is starting up and one in the method I call when the COM app is shutting down. The latter method shows the box.

I have a UI that lets me release and restart the .NET object. Once I am fully up and running if I create the .NET object, the box shows. So this seems to be related to when I call MessageBox.Show. It appears that .NET 4 simply cannot display a window when I make the call? Why? Is there a windows subsystem that is not yet ready?

All I have to do to fix the issue of MessageBox.Show not doing anything is go to the project/application setting and choose .NET 2. rebuild and run and the box shows. But chaning to .NET 2 negates the reason I have the box. With the .NET 2 setting, all my breakpoints work fine. That is, I can debug the code by launching the COM app as the debug targeta and debug as normal.

I know one cannot debug two .NET frameworks at once. I can run my COM app in debug and before I call CoCreateInstance on the .NET component I can see that there is no .NET runtime loaded. It loads when I call CoCreateInstance. Hence I am also confused as to why the .NET 2 shows the box AND lets me debug fine while the .NET 4 setting allows neither.

A standard trick to debug .NET components is to add a message box and when it shows up simply debug/attachtoprocess and pick the .NET runtime I want to debug. But this inexplicable non-appearance of the message box has killed that ability when it comes to .NET 4.

What is the difference between .NET 2 and 4 when it comes to displaying a window? And what about the difference when it comes to debugging in this scenario?


R.D. Holland

Paralell getting information from array

$
0
0

Hello!

I have some shell of array and several write and read methods. I want to get it thread-safe and have opportunity to get data from different threads at the same time.

For example:

class MyClass
{
public void Write1() {...}
public void Write2() {...}
public void Read1() {...}
public void Read2() {...}
}

So we could read from different threads at the same time, but lock thread which want to write data.

And in this way we can't use lock() operation or Monitor, because in this way we can call only one method(read or write) at the same time. What is the best way to do it?


Please help!! Having a problem with my web.config file

$
0
0

Hello!

I am getting an error inside Visual Studio and can't run my applications anymore. The error says could not load file or assembly 'Microsoft.Data.Edm' or one of it's dependencies.  I really need to fix this please someone have a look at my web.config file

<?xml version="1.0"?><configuration><configSections><sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"><sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"><!--<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
				--><sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"><!--<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
				  --><!--<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
					--><!--<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
					--><!--<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
				--></sectionGroup></sectionGroup></sectionGroup></configSections><appSettings/><connectionStrings/><system.web><!-- <customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx"/>

    
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
        --><compilation debug="true" strict="false" explicit="true"><assemblies><add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/><add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add assembly="AjaxControlToolkit, Version=3.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/></assemblies></compilation><pages><namespaces><clear/><add namespace="System"/><add namespace="System.Collections"/><add namespace="System.Collections.Generic"/><add namespace="System.Collections.Specialized"/><add namespace="System.Configuration"/><add namespace="System.Text"/><add namespace="System.Text.RegularExpressions"/><add namespace="System.Linq"/><add namespace="System.Xml.Linq"/><add namespace="System.Web"/><add namespace="System.Web.Caching"/><add namespace="System.Web.SessionState"/><add namespace="System.Web.Security"/><add namespace="System.Web.Profile"/><add namespace="System.Web.UI"/><add namespace="System.Web.UI.WebControls"/><add namespace="System.Web.UI.WebControls.WebParts"/><add namespace="System.Web.UI.HtmlControls"/></namespaces><controls><add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add tagPrefix="asp" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit, Version=3.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/></controls></pages><!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        --><authentication mode="Forms"/><!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.
   --><customErrors mode="RemoteOnly" defaultRedirect="Error.aspx"><!--<error statusCode="403" redirect="Error403.htm" /><error statusCode="404" redirect="Error404.htm" /><error statusCode="500" redirect="Error500.aspx" />
            --></customErrors><!--<customErrors mode="Off"/> --><httpHandlers><remove verb="*" path="*.asmx"/><add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/></httpHandlers><httpModules><add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpModules></system.web><system.codedom><compilers><compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><providerOption name="CompilerVersion" value="v3.5"/><providerOption name="OptionInfer" value="true"/><providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom><!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    --><system.webServer><validation validateIntegratedModeConfiguration="false"/><modules><remove name="ScriptModule"/><add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></modules><handlers><remove name="WebServiceHandlerFactory-Integrated"/><remove name="ScriptHandlerFactory"/><remove name="ScriptHandlerFactoryAppServices"/><remove name="ScriptResource"/><add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></handlers></system.webServer><!-- <runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/><bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly><dependentAssembly><assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/><bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly></assemblyBinding></runtime>
--><runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727"><dependentAssembly><assemblyIdentity name="AjaxControlToolkit" publicKeyToken="28f01b0e84b6d53e" /><bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.1005" /></dependentAssembly><dependentAssembly><assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/><bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.1005"/></dependentAssembly></assemblyBinding></runtime><!-- 
	Custom Binding to allow bigger attachment
  --><system.serviceModel><behaviors><serviceBehaviors><behavior name="TestLargeWCF.Web.MyServiceBehavior"><serviceMetadata httpGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="false"/></behavior></serviceBehaviors></behaviors><bindings><customBinding><binding name="customBinding0"><binaryMessageEncoding /><!-- Start change --><httpTransport maxReceivedMessageSize="5097152"
                         maxBufferSize="5097152"
                         maxBufferPoolSize="5097152"/><!-- Stop change --></binding></customBinding></bindings><serviceHostingEnvironment aspNetCompatibilityEnabled="true"/><services><service behaviorConfiguration="Web.MyServiceBehavior"             name="TestLargeWCF.Web.MyService"><endpoint address=""
                 binding="customBinding"
                 bindingConfiguration="customBinding0"
                 contract="TestLargeWCF.Web.MyService"/><endpoint address="mex"
                 binding="mexHttpBinding"
                 contract="IMetadataExchange"/></service></services></system.serviceModel><!-- 
	Ends here
  --><system.net><mailSettings><smtp from="nowhere@z.test"><network host="mail.rainbowschools.ca"/></smtp></mailSettings></system.net></configuration>


WebBrowser control Memory Leak

$
0
0
I created an .NET C#application to continuously creating and closing WebBrowser control for testing.  I noticed that my application memory usage has been going up per WebBrowser control.

I looked though some user group, and saw that there is apperantly a memory leak in WebBrowser control.

Here are my question:
1.  I would like this confirm if this is a known issue.
2.  Is there a fix or workaround available.

Many thanks,
Alice

Language Neutral Attribute is not supported in .net framework 4.0

$
0
0

We have a .NET class library which contains "Language Neutral" attribute in AssemblyInfo.VB file as shown below...

assembly:AssemblyCulture("Language Neutral")

When I reference this library in .NET 3.5 application or in corresponding SSIS packages.  It's working fine. 

But when I refer same assembly in .net 4.0 and above, I'm getting the error like "Language Neutral" attribute is not recognized. 

If I remove this attribute, it'll compile in .net framework 4.0.  But in my case, I've several SSIS packages which are built on top of .net framework 3.5 with above DLL.  All these packages will break if I don't recompile them with new component.  If I keep this attribute, I can't make new changes in .net framework 4.0 applications. 

Can you please suggest alternatives for this problem?


Rajeswar

Compiling and executing code using anonymous types with VBCodeProvider fails

$
0
0
Using VBCodeProvider I am trying to compile and execute a block of VB code that performs a LINQ query and then processes the results. Two problems:

1. The code will not compile unless the anonymous types are declared as Object 

2. After declaring as Object the methods are not found.

I have searched high and low for a solution but found nothing of any use.


Code to Compile (embedded in project as string resource)
---------------



    Imports System.Linq
    Imports System.Collections.Generic
    Imports System

    public Class Y

    Friend Shared Function Result() as Integer

    Dim gts As List(Of GtDef) = {New GtDef(1, "FirstGte"), New GtDef(2, "FirstGte")}.Cast(Of GtDef).ToList

    Dim evts As List(Of EvDef) = {New EvDef(1, 1, "FirstEv"), New EvDef(2, 1, "SecondEv"), New EvDef(3, 2, "SecondEv")}.Cast(Of EvDef).ToList

    Dim x = From g In gts Join e In evts On g.ID Equals e.ParentID Group e By key = e.ParentID Into Group Select GtGroup = key, EvGroup = Group

    Dim sum As Integer = x.Count()

    For Each gte In x
      For Each evt In gte.EvGroup
        sum += evt.ID
      Next
    Next

    return sum

    End Function

    End Class


    Public Class GtDef

    Public ID As Integer
    Public Name As String

    Sub New(id As Integer, name As String)

        Me.ID = id
        Me.Name = name

    End Sub

    End Class

    Public Class EvDef

    Public ID As Integer
    Public ParentID As Integer
    Public Name As String

    Sub New(id As Integer, parentID As Integer, name As String)

         Me.ID = id
         Me.ParentID = parentID
         Me.Name = name

      End Sub

    End Class

Code used run compiler
----------------------


    Dim compiler As Compiler.CodeDomProvider = Nothing

    Dim provOptions As New Dictionary(Of String, String)
    provOptions.Add("CompilerVersion", "v4.0")

    compiler = New Microsoft.VisualBasic.VBCodeProvider(provOptions)

    Dim compilerParams As New Compiler.CompilerParameters()

    Dim assems As String() = AppDomain.CurrentDomain.GetAssemblies().Where(Function(find) Not find.IsDynamic).Select(Function(find) find.Location).ToArray
    compilerParams.ReferencedAssemblies.AddRange(assems)

    Dim compResults As Compiler.CompilerResults = compiler.CompileAssemblyFromSource(compilerParams, {My.Resources.Code})

    Dim cls As Type = compResults.CompiledAssembly.GetType("Y")
    cls.InvokeMember("Result", System.Reflection.BindingFlags.InvokeMethod Or System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Static, Nothing, Nothing, Nothing)



Programmatically Disable or Set GPO to Not Configured

$
0
0

Looking for a programmatic solution that has the same effect as setting the "Configure Windows NTP Client" state in GPOEAdministrative Templates > System > Windows Time Service > Time Providers > Configure Windows NTP Client toNot Configured or Disabled.

Is there a registry key I can modify using the .NET Registry class or a property I can modify using the RSoP WMI classes or an element in the ADMX file I can modify that will effectively disable the GPO or have the same effect as disabling or setting it to Not Configured in the GUI?


New interfaces IReadOnlyList and IReadOnlyDictionary

$
0
0

Hello,

I apploud to the long-awaited intoduction of interfaces for read-only collections.

However, I also have some questions. First of all, why there's no general IReadOnlyCollection interface.

 

    public interface IReadOnlyCollection<out T> : IEnumerable<T>
    {
        int Count { get; }
    }

While I understand the resistance to add another interface for collections, there's a real lack of an interface for non-lazy read-only collection. IEnumerable may not serve that role. Introduction of IReadOnlyList and IReadOnlyDictionary is the last chance to also introduce IReadOnlyCollection, it would be almost impossible to introduce it afterwards, as it would mean that some classes that explicitly implement IList, IReadOnlyList and (independently of IReadOnlyList) IReadOnlyCollection have to implement Count trice.

 

Second question is about LINQ support for these interfaces. Will Enumerable.Count() be updated to check for these interfaces on sequences that do not support ICollection? Failing to do so, would mean that there's no way to have immutable collections with immutability visible from their interface (as collections will be forced to implement ICollection to support Enumerable.Count efficiently). 

And the third one. I understand that the support for these interfaces was driven by WinRT requirements. However these interfaces are usefull without WinRT as well. So, will other collections besides List<> and Dictionary<> be updated to support these interfaces?


Viewing all 8156 articles
Browse latest View live


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