I forgot to schedule the post below. It is still relevant if you create a machine with lots of Delphi versions on it.
Archive for the ‘.NET 2.0’ Category
VM disk sizes
Posted by jpluimers on 2018/06/29
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, Database Development, Delphi, Delphi 2007, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Firebird, InterBase, Power User, Software Development, Windows, Windows 8 | 2 Comments »
Windows 10 – language neutral batch file to start Windows Update
Posted by jpluimers on 2017/02/22
A while ago, I bitched that Microsoft moved away the Windows Update out of the Control panel into a language depended place (in Windows 10 1511 update broke the Hyper-V networking – Fix network connection issues).
Since then I had to maintain too many locales running Windows 10. So here is the batch file:
for /f "delims=" %%A in ('PowerShell -Command "(Get-Culture).Name"') do explorer "%LocalAppData%\Packages\windows.immersivecontrolpanel_cw5n1h2txyewy\LocalState\Indexed\Settings\%%A\AAA_SystemSettings_MusUpdate_UpdateActionButton.settingcontent-ms"
It uses these tricks:
- Set output of a command as a variable (in this case a for loop variable)
- Execute PowerShell script in a .bat file
- PowerShell Get-Culture (which gets a .NET CultureInfo instance)
- CultureInfo.Name property (which has the nl-NL, en-US, etc codes in it)
It replaced this simple batch-file which has worked for like 10 years:
%windir%\System32\rundll32.exe url.dll,FileProtocolHandler wuapp.exe
–jeroen
via: Windows Update Shortcut – Create in Windows 10 – Windows 10 Forums
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Batch-Files, CommandLine, Development, Power User, PowerShell, Scripting, Software Development, Windows, Windows 10 | Leave a Comment »
.NET/C# some links on querying the ActiveDirectory
Posted by jpluimers on 2016/12/15
Without dsquery installable, I had to query an ActiveDirectory spanning two domains.
Here are some links that helped:
- Howto: (Almost) Everything In Active Directory via C# – CodeProject.
- c# – How to query Active Directory for all groups and group members? – Stack Overflow
- c# – Difference between PrincipalSearcher.FindAll() and GroupPrincipal.FindByIdentity() – Stack Overflow
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
Unity IoC container: tips, tricks and dirty hacks
Posted by jpluimers on 2016/11/03
The #Fellows | Unity IoC container: tips, tricks and dirty hacks post is a very readable and to-the-point introduction to Unity IoC focussing on Dependency Injection. Implementation details of various IoC/DI frameworks differ, so some keywords:
- Container
- InjectionConstructor
- InjectionProperty
- Inversion of Control
- Named registration (or keyed registration)
- PerResolveLifetimeManager
- Register
- RegisterType
- Resolve
- ResolvedParameter
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
Yes Dorothy, the .NET System.Array Class can throw you a NotSupportedException
Posted by jpluimers on 2016/09/21
It’s been in the System.Array class forever, but remarkably few people do know that it can throw you a NotSupportedException (for instance when calling Add, Insert, Remove, etc).
It does because it implements IList, but not all methods implemented from IList are valid.
And it also indicates that, as the IList Properties allows for IsFixedSize to return false.
A similar case is there for IsReadOnly: then you cannot even modify the values.
Ever since I started teaching .NET/C# classes almost 15 years ago, I warned:
beware when you use IList as not everybody implements all methods.
–jeroen
via:
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
.NET/C#: two ways of creating an empty array
Posted by jpluimers on 2016/08/18
Empty arrays are not used often as arrays usually are about the presence data, not about the absence.
Here are two ways based on the int data type in C# (the original [WayBack] examples [WayBack] are using string, but since string itself is also a kind of array…):
Specify a size of zero:
int[] a = new int[0];
Specify an empty initialisation:
int[] a = new int[] { };
Though many people think arrays are a thing of the past, I think it is one of the first generic types and have their place. For one, enumerating over arrays using foreach is a lot faster in many environments than enumerating over other data types. Another thing is that the fixed nature of arrays can be very beneficial in setting constraints.
That’s why I like the balanced view from Eric Lippert [WayBack] in Arrays considered somewhat harmful – Fabulous Adventures In Coding – Site Home – MSDN Blogs [WayBack]
–jeroen
via:
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
C#, XSD.exe, xsd2code and generating nullable fields+properties from an XSD with and without Specified fields/properties
Posted by jpluimers on 2016/07/27
It comes down to these cases for XML elements having maxOccurs="1" (which the default for maxOccurs):
- adding
nillable="true"will convert from a regular type to a nullable type. - adding
minOccurs="0"will add boolean …Specified properties in the generated C# for each element. - you can have both
nillable="true"andminOccurs="0"in an element which gets you a nullable type and a …Specified property.
Note I’m not considering
fixedordefaulthere, norattributes(that haveuseinstead ofminOccurs/maxOccurs, but do not allow for nillable) nor larger values ofmaxOccurs(which both xsd.exe and xsd2code regard asunbounded).
From the above, XML has a richer type system than C#, so in XML there are subtle a differences between:
- an explicit
nilin the XML element - the XML element being absent
- the XML element being empty.
Hopefully later more text and examples to show how to actually work with this.
- XML Schema nillable=”true” vs minOccurs=”0″ | Dimuthu’s Blog.
- Web services tip: Representations of null in XML Schema.
- c# – Nullable value with xsd.exe genereated class – Stack Overflow.
- Simon Fell > Its just code > Nullable and XxxSpecified.
- Knucklebones: How to NOT use XSD.EXE (it mentions xsd2code which is maintained and XmlGen# which is not maintained).
- Nullable type and XML xsd.exe tool – .NET Development – Windows Tech (xsd.exe .NET DataSets code generation don’t support Nullable).
- c# – Comparison of XSD Code Generators – Stack Overflow.
- .net – Serialize nullable type to optional non-nillable element – Stack Overflow.
- c# – Setting minOccurs=0 in a WSDL using “Specified” pattern not working – Stack Overflow.
- c# – Is it valid to set nillable=true and use the default property in an XML document? – Stack Overflow.
- xml – nillable and minOccurs XSD element attributes – Stack Overflow.
- Web services tip: Representations of null in XML Schema.
- XSD tool appends “Specified” to certain properties/fields when generating C# code – Stack Overflow: watch for semantics differences between C# and XML.
- Using the *Specified Properties in Exchange 2010.
- Name of the blog | Xml Serialization.
- c# – Nullable value with xsd.exe genereated class – Stack Overflow.
Delphi related to minOccurs:
- [WayBack] Problem with optional parameters in a remote function – delphi
- Wayback Machine QC 24056 is unavailable
- [WayBack] QualityCentral 73096 – Reported – Missing empty line in auto-generated code for node collections
- [RSP-16448] WSDL Importer has problems with tags in berlin – Embarcadero Technologies
- [RSP-19690] XML Data Binding Wizard creates wrong datatype – Embarcadero Technologies
- [WayBack] Delphi XML binding wizard and optional elements – Stack Overflow
Note that xsd2code.codeplex.com (unlike XmlGen#) has at least two forks at github:
From the specs:
- XML Schema Part 0: Primer Second Edition.
- XML Schema Part 1: Structures Second Edition.
- XSD.exe XML Schema Binding Support:
- XML Schemas (XSD) Reference:
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Conference Topics, Conferences, Development, Event, Software Development, XML, XML/XSD, XSD | Leave a Comment »
Easy way to generate “System.InvalidOperationException: Nullable object must have a value.”
Posted by jpluimers on 2016/07/07
Easy way to generate “System.InvalidOperationException: Nullable object must have a value.”.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| public class Test | |
| { | |
| public static void Main() | |
| { | |
| int? nullableInt = null; | |
| int nowInt = (int)nullableInt; | |
| } | |
| } |
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
csc.exe: prevent “does not contain a static ‘Main’ method suitable for an entry point”, use /target:library
Posted by jpluimers on 2016/06/29
Every once in a while I do Command-line Building With csc.exe.
When building libraries, it throws this error:
The reason is that by default it wants to build a program.
Change this default by adding the /target:library parameter.
–jeroen
via: c# – Program does not contain a static ‘Main’ method suitable for an entry point – Stack Overflow.
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Development, Software Development, Visual Studio 11, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio 2012, Visual Studio 2013, Visual Studio 2014, Visual Studio 2015, Visual Studio and tools | Leave a Comment »
Batch file to run the most recent vsvars32.bat
Posted by jpluimers on 2016/06/28
The below batch file finds and runs the latest vsvars32.bat on a system.
vsvars32.bat initializes the path and other environment variables to run Visual Studio and command-line tools (like csc.exe, xsd.exe, editbin.exe).
The batch file employs a few tricks from:
- EnableDelayedExpansion | Windows CMD | SS64.com.
- Windows batch: how to assign variable with dynamic name? – Stack Overflow.
- batch file – Assign variables past endlocal in a loop – Stack Overflow.
:: Run the most recent vsvars32.bat :: test these environment variables that have 110 or 120 in them (future enhancements: support more Visual Studio versions): :: Visual Studio .NET 2002: VS70COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio .NET\Common7\Tools\ :: Visual Studio .NET 2003: VS71COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Common7\Tools\ :: Visual Studio 2005: VS80COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Tools\ :: Visual Studio 2008: VS90COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\ :: Visual Studio 2010: VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\ :: Visual Studio 2012: VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\ :: Visual Studio 2013: VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\ :: VS130COMNTOOLS was skipped: http://www.neowin.net/forum/topic/1215607-visual-studio-13-to-be-skipped-vnext-to-be-v14/ :: Visual Studio 2015: VS130COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\ :: They contain `vsvars32.bat` which will update the `PATH` so it includes where `xsd.exe`, `csc.exe`, `editbin.exe` and others reside :: Different examples: https://github.com/noop-dev/c-cgdk/blob/master/compile-vscpp.bat :: and https://code.google.com/p/xvid4psp/source/browse/trunk/bin/4Gb+patcher.bat :: or give it a go for any version: http://chess.eecs.berkeley.edu/ptexternal/src/ptII/ptolemy/actor/lib/fmi/fmus/template/sources/build_fmu.bat setlocal enabledelayedexpansion :: delayed expansion allows for the exclamation marks :: see http://ss64.com/nt/delayedexpansion.html :: see http://stackoverflow.com/questions/22857407/windows-batch-how-to-assign-variable-with-dynamic-name for %%v in (70 71 80 90 100 110 120 130) do if not [!VS%%vCOMNTOOLS!]==[] set VSCOMNTOOLS=!VS%%vCOMNTOOLS! :: http://stackoverflow.com/questions/28682268/assign-variables-past-endlocal-in-a-loop endlocal & call :do call "%VSCOMNTOOLS%vsvars32.bat" goto :eof :do echo %* %* goto :eof
–jeroen
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Development, Software Development, Visual Studio 11, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio 2012, Visual Studio 2013, Visual Studio 2014, Visual Studio 2015, Visual Studio and tools | Leave a Comment »





