Archive for the ‘.NET’ Category
Posted by jpluimers on 2015/11/18
I missed when the StackExchange App for Android was finally launched, but I totally agree with Paul Lammertsma :
Exceeds expectations This was a long time coming, but it didn’t disappoint. It’s a great aid for a regular on Stack Overflow like me!
–jeroen
via Stack Exchange – Android Apps on Google Play .
Posted in .NET , Delphi , Development , Pingback , Power User , Software Development , Stackoverflow | Leave a Comment »
Posted by jpluimers on 2015/11/17
If you ever need a universal Android ADB driver for Windows, then use this one: koush/UniversalAdbDriver .
I never noticed it was there until Koushik Dutta posted about a signing trick on Google+ .
Windows drivers need to be signed, so what he does is generate a self signed certificate on the fly during installation, sign the driver install it, and drop the private key of the certificate.
Each installation has its own key, Microsoft is happy, and it is proven the driver signature mechanism in Windows has a hole.
If you want to do similar things, then this commit is what you are looking for: Use a self signed, self destructing signing cert. · e8b78fe · koush/UniversalAdbDriver .
It isn’t rocket science, but not trivial C# either, so this is a great example of something that works.
–jeroen
Posted in .NET , Android , C# , Development , Mobile Development , Software Development | Leave a Comment »
Posted by jpluimers on 2015/11/11
Really exiting times ahead: Microsoft .Net on Linux.
It’s not fully ready yet, but to get an idea to learn more about running OpenShift Enterprise 3 and a .NET application based on a Red Hat Enterprise Linux container, here are a few links to get started:
I wish that the demo repository at https://github.com/munchee13/snoopalicious.git and the rhosepaas.com domain were accessible (:
There are other alternatives too, but OpenShift (RedHat) and Microsoft working together is really exiting news to me.
If you’re on other distros, here are some more links:
And of course there has been Mono for a while, which is a different implementation of .NET:
Hopefully this will have search results soon: dnvm opensuse tumbleweed .
–jeroen
Posted in *nix , .NET , Development , Linux , OpenShift , openSuSE , Power User , RedHat , Software Development , SuSE Linux , Tumbleweed | Leave a Comment »
Posted by jpluimers on 2015/11/04
From a chat with a co-worker a while ago:
I’m not against properties. Just something against properties properties that are objects with writeable fields.
So even if you expose such a property as read-only, it can still get its writeable fields overwritten.
That is a pain when those are part of the state of the underlying object.
In other words: encapsulate your state changes.
Here we solved it by making
the type of the property immutable
the property writeable
react on state changes during the write
Proper encapsulation.
In this case it was a project mixing C# and Delphi, but you can easily apply the above to any language featuring classes and properties.
Another solution would have been to extend the type of the property so it can expose an event that fires during change. Much more convoluted.
–jeroen
Posted in .NET , C# , C# 1.0 , C# 2.0 , C# 3.0 , C# 4.0 , C# 5.0 , C# 6 (Roslyn) , Delphi , Delphi 10 Seattle , Delphi 2007 , Delphi 2009 , Delphi 2010 , Delphi XE , Delphi XE2 , Delphi XE3 , Delphi XE4 , Delphi XE5 , Delphi XE6 , Delphi XE7 , Delphi XE8 , Development , Software Development | 2 Comments »
Posted by jpluimers on 2015/11/03
Lazy<T> is not constrained to static contexts.
Instance field initialisers cannot use instance references (but can use static references) as they run outside of the constructor.Though there are arguments for instance field initialisers too ., I think this is a good reason to initialise fields inside the constructor: there you do have access to instance references (but should not call virtual instance methods or properties ) which leads to another reason: consistency as field initialisers run in the opposite hierarchy order as constructors (incidentally causing this virtual method restriction).
Boy, that was a long sentence (:
–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 »
Posted by jpluimers on 2015/10/27
Today it is about the curse of
ORA-12560: TNS:protocol adapter error
Don’t you love the overly generic error messages you often get, especially from Oracle.
We log the additional information which doesn’t bring much help either:
Errors:Oracle.DataAccess.Client.OracleErrorCollection ; Number: 12560
There is so much that can cause the Oracle 12560 error (including spurious SSL things ), that it is often like searching for a needle in a haystack.
What in fact happened is that in a few of our .NET config files got empty ConnectionString attributes for Data Source, User Id and Password as this fragment shows:
connectionString=”Data Source=; User Id=; Password=;”
The cause was a parameter substitution step in our build process where we generate each config file based on templates. It failed on some of them as this simple grep query can reveal:
grep -ind connectionstring\=.*\=; *.config
grep -indl connectionstring\=.*\=; *.config
The first one shows the files and lines, the second one only the files.
So we now have some guarding in place that will prevent these attributes to become empty.
–jeroen
Posted in .NET , .NET 4.0 , .NET 4.5 , C# , C# 3.0 , C# 4.0 , C# 5.0 , C# 6 (Roslyn) , Database Development , Development , OracleDB , Software Development | Leave a Comment »
Posted by jpluimers on 2015/10/21
It’s not reproducible yet, so I need to find out why under some rare circumstances, devenv.exe (the Visual Studio IDE) generated build.force files. Sometimes the build then fails, most of the times it succeeds.
Hopefully this has to to with non-project references .
Research links:
–jeroen
Posted in .NET , Development , Software Development , Visual Studio 2013 , Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2015/10/07
A long time ago, there was an interesting discussion here: I was wondering, that what is the closest value to the Zero floating point can have .
Recently I needed to do some calculations on series where getting close to zero could become a problem.
Math seems to have an Epsilon of 1E-12.
Sytem.Types has Epsilon of 1E-30 and Epsilon2 of 1E-40.
XE4+ FMX has IsEssentiallyZero and IsNotEssentiallyZero for Single values.
In practice it depends a lot on what you are doing. Sometimes absolute Epsilons are best, but at other times relative difference is much more applicable.
Then there is also a Machine Epsilon : a way to derive an Epsilon from a data type that works in all languages and platforms.
–jeroen
Posted in .NET , Algorithms , C , C# , C++ , Delphi , Development , Floating point handling , Software Development | 1 Comment »
Posted by jpluimers on 2015/10/06
Get the path to the most recent msbuild.exe from the registry :
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
@echo off
:: http://stackoverflow.com/questions/328017/path-to-msbuild
:: http://www.csharp411.com/where-to-find-msbuild-exe/
:: http://timrayburn.net/blog/visual-studio-2013-and-msbuild/
:: http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx
setlocal
:vswhereModernTry
:: https://github.com/Microsoft/vswhere/wiki/Find-MSBuild
:: Normal output example of `vswhere -legacy -latest -property installationPath` has no trailing back-slash:
:: `C:\Program Files (x86)\Microsoft Visual Studio 14.0\`
for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set InstallDir=%%i
)
:: without ENABLEEXTENSIONS, %InstallDir% is only available outside the above loop.
for %%v in (15.0, 14.0) do (
if exist "%InstallDir%\MSBuild\%%v\Bin\MSBuild.exe" (
set msBuildExe="%InstallDir%\MSBuild\%%v\Bin\MSBuild.exe"
goto :finish
)
)
:manualTry
:: order of the versions is important: get the most recent one
for %%v in (14.0, 12.0, 4.0, 3.5, 2.0) do (
for /f "usebackq tokens=2* delims= " %%c in (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\%%v" /v MSBuildToolsPath`) do (
set msBuildExe="%%dMSBuild.exe"
goto :finish
)
)
:vswhereLegacyTry
:: -legacy is not compatible with -products or -requires
:: note there is no Visual Studio 13.0 (just like there is no Office 13.0) likely because USA superstition.
:: https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#History
:: msbuild was introduced in Visual Studio 8.0: https://en.wikipedia.org/wiki/MSBuild#History
:: Legacy output example of `vswhere -legacy -latest -property installationPath` has trailing back-slash:
:: `C:\Program Files (x86)\Microsoft Visual Studio 14.0\`
for /f "usebackq tokens=*" %%i in (`vswhere -legacy -latest -property installationPath`) do (
set InstallDir=%%i
)
:: without ENABLEEXTENSIONS, %InstallDir% is only available outside the above loop.
for %%v in (14.0, 12.0, 11.0, 10.0, 9.0, 8.0) do (
if exist "%InstallDir%MSBuild\%%v\Bin\MSBuild.exe" (
set msBuildExe="%InstallDir%MSBuild\%%v\Bin\MSBuild.exe"
goto :finish
)
)
:: nothing found
:finish
endlocal & if not [%msBuildExe%]==[] if exist %msBuildExe% ( echo %msBuildExe% )
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
for /f " usebackq tokens=*" %%c in (`" %~dp0 get-msbuildExe-path.bat" `) do (
call %%c %*
)
With help from:
Note
This needs adoption for Visual Studio 2017 (15.0) and up; see the comments at the above gist :
–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) , Delphi , Delphi 10 Seattle , Delphi 2007 , Delphi 2009 , Delphi 2010 , Delphi XE , Delphi XE2 , Delphi XE3 , Delphi XE4 , Delphi XE5 , Delphi XE6 , Delphi XE7 , Delphi XE8 , Development , Software Development | Leave a Comment »
lextm commented on Mar 9, 2017 •
vswhereis now recommended to locate MSBuild 15,https://github.com/Microsoft/vswhere
n9 commented on May 17, 2017
vswhere -products *to get standalone installation of BuildTools. (See Microsoft/vswhere#61.)