unsafe

AngularJS ng-src in ie8: image not loaded and “unsafe” added to path

雨燕双飞 提交于 2019-12-11 04:14:19
问题 I just wanted to add an image to my app. As advised, I used the ng-src directive: <img ng-src="{{app.imgBig}}" alt="lorem ipsum" height="100" width="200" title="lorem ipsum" /> It works fine on most browsers but it doesn't on IE8. The image is not loaded as instead of adding the absolute url to the file name, it returns the relative path and adds " unsafe: " before it. Actually, it's trying to load: unsafe:img/test.jpg Instead of: http://url_of_my_site.com/img/test.jpg So you know, it may be

How to use an anonymous class instance in another generate bytecode class

梦想的初衷 提交于 2019-12-11 03:58:56
问题 I have difficulty in using a generated bytecode class which is loaded by Unsafe.defineAnonymousClass() . I am wondering how to use an object of anonymous class to initiliaze another class (or anonymous class). Take an example class Callee below for example, its constructor accepts Callee2 as parameter. Class Callee{ Callee2 _call2; public Callee(Callee2 callee2){ ... } } During runtime, I generated new classes for both Callee2 and Callee, and both new classes are loaded by Unsafe

Can I use a C# dll with unsafe code in VB.NET?

痞子三分冷 提交于 2019-12-11 03:21:06
问题 There is an FastBitmap class for C#, that lets you acces and modify pixel information of am bitmap. I have already used it in some C# project, but I need it now in VB.NET. The problem is that that class uses unsafe code, that is not supported in VB.NET. The question is. Can I compile the FastBitmap class in a dll and use it in VB.NET? [EDIT] Or is there some library that can be used to modfy pixel data in VB.NET? 回答1: Yes, you can do that. If the class doesn't expose any unsafe features in

The performance of `unsafe` in Java and C#

烂漫一生 提交于 2019-12-11 03:21:02
问题 I'm trying to learn digital image processing, I found my friend using c#. There is a very important reason why he using C#: There is unsafe keyword in c# and the performance of his code(algorithm part) can reach 75% of same code in c++, which is good enough for him. He encourages me to turn to c#, but I'm java programmer of many years. I know there is a Unsafe class in java too, but I have never used of it, not sure if the performance is as good as C#. So I want to know the performance of

.NET Micro Framework Unsafe code

空扰寡人 提交于 2019-12-11 02:07:01
问题 Does .NET Micro Framework support unsafe code? In other words, can I use pointers in my code for .NET Micro Framework? 回答1: From the Wikipedia page (emphasis mine): For example, the platform does not support symmetric multiprocessing, multi-dimensional arrays, machine-dependent types, or unsafe instructions . The technical white paper lists it in the omitted features too. 回答2: Although officially not supported, I have personally used and tested unsafe code in NETMF 4.2 and find that it works

How to convert fixed byte/char[100] to managed char[] in C#?

落爺英雄遲暮 提交于 2019-12-11 01:27:28
问题 What's the best way to convert a fixed byte or char[100] to a managed char[] in C#? I ended up having to use pointer arithmetic and I'm wondering if there is an easier way -- something like a memcpy or another way? using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; namespace StructTest { [StructLayout(LayoutKind.Explicit)] unsafe struct OuterType { private const int BUFFER_SIZE = 100; [FieldOffset(0)] private int

A pointer type static field's value is displayed as zero 0x0 by the debugger while it actually has a valid value

99封情书 提交于 2019-12-10 18:12:49
问题 I came across this behaviour while trying to access the value of a struct's static field with type uint* While debugging, watch window shows the static field StaticBitMask 's value as zero, but actually (and as expected) it is a valid pointer, and Console.WriteLine() prints it, as can be seen in the console output below: Pointers: ----------------- Static bitmask pointer: 0x706790 Instance bitmask pointer: 0x708A20 Values: ----------------- Static bitmask pointer val: 0xFFFFFFFF Instance

Take the address of a ref parameter

[亡魂溺海] 提交于 2019-12-10 17:26:00
问题 My code is as follows class MyClass { static int iField = 42; static void Test(ref int arg) { unsafe { fixed(void* pField = &iField) fixed(void* pArg = &arg) { Console.WriteLine ("{0},{1}",(int)pArg,(int)pField); //output: 165451772,165451772 } } } static void Main() { Test(ref iField); } } I'd like to know if taking address of ref parameters is as reliable as it showed above in the test. 回答1: As far as I know, yes while you are in the fixed block, the GC will not relocate arg . Once outside

Calling a C++ function from C# - unbalanced stack

这一生的挚爱 提交于 2019-12-10 16:54:31
问题 I have a unmanaged C++ function with the following signature: int function(char* param, int ret) I am trying to call it from C#: unsafe delegate int MyFunc(char* param, int ret); ... int Module = LoadLibrary("fullpathToUnamanagedDll"); IntPtr pProc = GetProcAddress(Module, "functionName"); MyFunc func = (MyFunc)System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(pProc, typeof(MyFunc)); unsafe { char* param = null; int ret = 0; int result = func(param, ret); } As far as I can

Java unchecked operation cast to generic

风格不统一 提交于 2019-12-10 16:43:25
问题 I am wondering why the following issues a warning about an unsafe / unchecked operation: Map<String, ProxySession> sessionMap = (Map<String, ProxySession>) se.getSession().getServletContext().getAttribute("myattribute"); Is the cast wrong? I can't understand what I am missing here. P.S. I don't want to get rid of the warning, I want to understand the unsafe operation. Thanks! 回答1: It means that the cast will check that the returned object is a Map of some kind, but it won't be able to check