clr

Validating decimal in C# for storage in SQL Server

ⅰ亾dé卋堺 提交于 2019-12-04 17:07:23
I have a decimal database column decimal (26,6) . As far as I can gather this means a precision of 26 and a scale of 6. I think this means that the number can be a total of 26 digits in length and 6 of these digits can be after the decimal place. In my WPF / C# frontend I need to validate an incoming decimal so that I can be sure that it can be stored in SQL Server without truncation etc. So my question is there a way to check that decimal has a particular precision and scale. Also as an aside I have heard that SQL Server stores decimal in a completely different way to the CLR, is this true

How does coding with LINQ work? What happens behind the scenes?

烈酒焚心 提交于 2019-12-04 16:49:30
For example: m_lottTorqueTools = (From t In m_lottTorqueTools _ Where Not t.SlotNumber = toolTuple.SlotNumber _ And Not t.StationIndex = toolTuple.StationIndex).ToList What algorithm occurs here? Is there a nested for loop going on in the background? Does it construct a hash table for these fields? I'm curious. Query expressions are translated into extension method calls, usually. (They don't have to be, but 99.9% of queries use IEnumerable<T> or IQueryable<T> .) The exact algorithm of what that method does varies from method to method. Your sample query wouldn't use any hash tables, but joins

What are the differences in JIT between Java and .Net

早过忘川 提交于 2019-12-04 16:48:36
问题 I know Microsoft .NET uses the CLR as a JIT compiler while Java has the Hotspot. What Are the differences between them? 回答1: They are very different beasts. As people pointed out, the CLR compiles to machine code before it executes a piece of MSIL. This allows it in addition to the typical dead-code elimination and inlining off privates optimizations to take advantage of the particular CPU architecture of the target machine (though I'm not sure whether it does it). This also incurs a hit for

Call dll function works in IronPython, doesn't work in CPython3.4 gives “No method matches given arguments” error

烂漫一生 提交于 2019-12-04 16:34:06
For a project I need to include a DLL in Python. I'm using CPython3.4 and for including the dll I use pythonnet clr module (pythonnet-2.0.0.dev1-cp34-none-win_amd64.whl). In the dll I need a function that gives me a continuous update of a measurement. The dll is written in VB.net, the function that I need is shown below: Public Sub AdviseStart(ByVal item As Integer, ByVal a As Action(Of Object)) Implements IConversation.AdviseStart _parameterPoller.RegisterCallback(item, a) End Sub This is the code that I have written in python to call this function: import clr clr.AddReference('dll name')

Is it possible to use branch prediction hinting in C#?

淺唱寂寞╮ 提交于 2019-12-04 16:03:06
问题 For example, I know it is defined for gcc and used in the Linux kernel as: #define likely(x) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0) If nothing like this is possible in C#, is the best alternative to manually reorder if-statements, putting the most likely case first? Are there any other ways to optimize based on this type of external knowledge? On a related note, the CLR knows how to identify guard clauses and assumes that the alternate branch will be taken, making

LNK2028 Managed C++ DLL calling function in another Managed C++ DLL

时光毁灭记忆、已成空白 提交于 2019-12-04 15:54:02
I'm using VS2010 with a managed C++ DLL calling a function in another managed C++ DLL and I'm getting many LNK2028 link errors that look like this. 1>udpPkt.obj : error LNK2028: unresolved token (0A0000AA) "unsigned short __cdecl ComputeCrc16(void const *,unsigned int)" (?ComputeCrc16@@$$FYAGPBXI@Z) referenced in function "public: short __thiscall CPrivateUdpPkt::ComputeCrc(void)const " (?ComputeCrc@CPrivateUdpPkt@@$$FQBEFXZ) When I use dumpbin /export on the called DLL I see the unresolved function listed as: 7 6 00001040 ?ComputeCrc16@@YAGPBXI@Z = ?ComputeCrc16@@YAGPBXI@Z ( unsigned short _

Loader lock (regsvr32 R6033 error) with managed C++ dll

感情迁移 提交于 2019-12-04 14:57:11
I have a C++ dll which implements several COM interfaces, that I'm trying to migrate to managed C++. I set the /clr compiler flag and changed the Runtime Library property from /MT to /MD to avoid the conflict between these two flags, but that's all I've changed. When it attempts to register the dll during the build process, I get the following error: R6033 - Attempt to use MSIL code from this assembly during native code initialization This indicates a bug in your application. It is most likely the result of calling an MSIL-compiled (/clr) function from a native constructor or from DllMain. I

Are signed .net assemblies ever fully verified when loaded, to check they haven't been modified?

柔情痞子 提交于 2019-12-04 14:53:57
I used to think that .net assemblies that were signed and/or strong-named were verified by the CLR when loaded, meaning that it wasn't possible for someone to edit the IL and still have a valid assembly. Then I listened to this great Herding Code podcast where Jon McCoy said that doesn't really happen (approx 12:47 in the podcast) - i.e. anyone can edit the IL and mess with your assembly and the CLR will not care. I know this sounds weird, but he seems to know what he's talking about, so perhaps it's just that I don't know exactly what scenarios he's referring to. Can someone explain if & when

Oracle Data Provider to CLR type mapping

99封情书 提交于 2019-12-04 14:42:54
Where can I find the listing of ODP to CLR type mapping? On Oracle database, the NUMBER(9,0) type comes out in .NET app as System.Decimal from the MS Oracle driver, but as System.Int32 from ODP driver. I need an exact specification of types coming out from database (not the CLR to DB parameter mapping). Run this simple test to get mappings for SqlServer and Oracle (both MS and ODP.NET drivers): using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using Oracle.DataAccess.Client; namespace DbOutTypeTest { public class Program {

Cpython interpretter / IronPython interpretter No module named clr

强颜欢笑 提交于 2019-12-04 14:11:18
问题 i'm using IronPython and i want to create some windows form, i want to create a windows form with some button, and i want to do this in visual studio with iron python, i'm using visual studio 2012 integrated edition, each time i create an "ironpython windows form" project, when i want to run it, it says: The project is currently set to use the .NET debugger for IronPython debugging but the project is configured to start with a CPython interpreter. To fix this change the debugger type in