runtime

Replace existing class definition at runtime with newly created type

China☆狼群 提交于 2019-12-13 02:56:14
问题 Demorepo : https://github.com/gabbersepp/csharp-dynamic-replace-class How to use : Checkout Compile Delete TestLib.dll & TestLib.pdb from console/bin/Debug Execute console.exe through cmd Read first : I have something in mind I want to achieve at work and I think that this would be the best solution. So please do not discuss if I can solve this with another way. If I would like to discuss about this, I will create a new SO post. Given : A class in a lib: namespace Test.TestLib { public class

Powershell 2.0 Runtime exception; could not load file or assembly

自古美人都是妖i 提交于 2019-12-13 02:56:09
问题 The scenario that I am trying to rectify is one in which dlls are found when C# is compiled but not found when the c# code is executed. This is Powershell 2.0. Our policy is to not use the GAC. The c# code in a Powershell function is similar to this: function functionDef { [System.Reflection.Assembly]::LoadFrom("c:\myDir\func1.dll") [System.Reflection.Assembly]::LoadFrom("c:\myDir\func2.dll") $ref = @("c:\myDir\func1.dll","c:\myDir\func2.dll") $cCode = @" using System; using func1; using

Using UI Editor at runtime on a button click

若如初见. 提交于 2019-12-13 02:51:01
问题 I have a custom UI Editor for a property in C# . The editor works fine at design time. How ever I want to lauch the editor on click of a button at runtime. How can I do this? Thanks, Datte 回答1: Using a UITypeEditor in custom (i.e. runtime) scenarios is definitely a trick proposition. The most obvious part about launching a UITypeEditor is quite trivial: Just cast the instance to UITypeEditor and call EditValue or whatever other method you want. One of the hardest parts about using them is

How to stop ffmpeg that runs through java process

ε祈祈猫儿з 提交于 2019-12-13 01:14:25
问题 I am running ffmpeg in Java. Using p = Runtime.getRuntime().exec(command); It is used to stream video through a red5 server. My problem is that ffmpeg requires "q" to be pressed in order to stop. How can I do that? How can I send the q character to the running process so it will execute p.destroy(); or something similar? At the moment it runs forever until I kill the process in the task manager. I am using Windows7. 回答1: To inject the 'q' key into the running process, you can do something

Resize a QWidget containing a QVBoxLayout in runtime when contents are partially Hidden

谁说胖子不能爱 提交于 2019-12-13 00:31:58
问题 In this application, a list of HBoxLayouts is generated and put into a VBoxLayout in order to form a dynamically filled list of commands. There is a button above each sub-list which has the capability to hide the controls below it. The problem: when a sub-list is hidden, the widget which contains the broadest VBoxLayout does not change in size! The VBoxLayout then stretches to compensate. I want the container widget to shrink when it contains fewer items! It looks like this: The problem is,

How to run Linux program from Java code

五迷三道 提交于 2019-12-13 00:28:04
问题 I am trying to create a disk space from Java code using qemu-img so I instantiated process and runtime classes. When run the program the command is not executed though I used the same mechanism for similar execution and it work fine. So I am wondering whether I miss something here. StringBuilder commandBuilder = new StringBuilder("qemu-img create -f "+chosenStorageType+" ~/"+storageName+".img "+storageSize+"M"); System.out.println(commandBuilder); String command = commandBuilder.toString();

Getting type of items of a List at run-time in c#

只谈情不闲聊 提交于 2019-12-13 00:11:38
问题 I need an expression that gets type of every item of a collection. I have a collection like this: var collection = new List<object>{1,2.2,"string",'c'}; It's possible to get type of every item of collection like this: var myVariable= collection.Select(item => item.GetType()) But I need creation of this expression at run-time. I have to create something like myVariable dynamically, but how?! Debugger shows me value of internal expression of myVariable like this: {System.Linq.Enumerable

Dynamic constructor in C#

旧巷老猫 提交于 2019-12-12 19:12:24
问题 I am trying to write a method GetDynamicConstructor<T> which will return, essentially, a smart constructor for the given class. It will accept an array of strings as parameters and parse them as the appropriate type (given existing constructor data). public void Init() { DynamicConstructor<MyClass> ctor = GetDynamicConstructor<MyClass>(); MyClass instance = ctor(new string[] { "123", "abc" }); // parse "123" as int } public delegate T DynamicConstructor<T>(string[] args); public

Determine if matlab runtime is installed(preferably using Java)

孤街浪徒 提交于 2019-12-12 18:07:36
问题 I have a Java application that at some point calls on a Matlab executable . For now I just tell the user to install the included runtime manually but I would like to avoid it. What I'm looking for is a way of determining what version of Matlab runtime(if any) is installed and in case the required version is not installed I'll prompt the user with an option of running the installer. How can I check for Matlab runtime(preferably using Java)? 回答1: I think you're talking about running compiled

C runtime error with for loop

筅森魡賤 提交于 2019-12-12 17:29:58
问题 I wrote a small snippit of code that I thought would work, and I am getting all the values displayed in the console but shortly thereafter I am getting an runtime error. Anyone have any idea why? #include <stdio.h> int array[10]; void main() { int i; for(i = 0; i < 10; i++){ array[i] = i; printf("%i", array[i]); } return; } Output: Runtime error time: 0 memory: 2248 signal:-1 0123456789 Any help would be appreciated, thanks! 回答1: Declare function main as int main() and either remove statement