Hi everyone,
I would like to implement screen recorder in C#. But it seems
Windows Media Encoder 9 Series and SDK are not available anymore.
What SDK should I use instead?
Thanks,
Yuliya
Hi everyone,
I would like to implement screen recorder in C#. But it seems
Windows Media Encoder 9 Series and SDK are not available anymore.
What SDK should I use instead?
Thanks,
Yuliya
if (AccessReply != IntPtr.Zero) flag = AuthzFreeHandle(AccessReply); if (hManager != IntPtr.Zero) flag = AuthzFreeResourceManager(hManager); if (pClientContext != IntPtr.Zero) flag = AuthzFreeContext(pClientContext); AuthzFreeCentralAccessPolicyCache();
using Imanami.GroupID.DataTransferObjects.DataContracts.Replication; using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Security.Principal; namespace EffectiveRightsUsingAuthzAPI { public class Helper { [DllImport("advapi32.dll", SetLastError = true)] static extern uint GetEffectiveRightsFromAcl(IntPtr pDacl, ref TRUSTEE pTrustee, ref ACCESS_MASK pAccessRights); [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 4)] struct TRUSTEE { IntPtr pMultipleTrustee; // must be null public int MultipleTrusteeOperation; public TRUSTEE_FORM TrusteeForm; public TRUSTEE_TYPE TrusteeType; [MarshalAs(UnmanagedType.LPStr)] public string ptstrName; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 4)] public struct LUID { public uint LowPart; public int HighPart; } [StructLayout(LayoutKind.Sequential)] public struct AUTHZ_ACCESS_REQUEST { public int DesiredAccess; public byte[] PrincipalSelfSid; public OBJECT_TYPE_LIST[] ObjectTypeList; public int ObjectTypeListLength; public IntPtr OptionalArguments; }; [StructLayout(LayoutKind.Sequential)] public struct OBJECT_TYPE_LIST { OBJECT_TYPE_LEVEL Level; int Sbz; IntPtr ObjectType; }; [StructLayout(LayoutKind.Sequential)] public struct AUTHZ_ACCESS_REPLY { public int ResultListLength; public IntPtr GrantedAccessMask; public IntPtr SaclEvaluationResults; public IntPtr Error; }; public enum OBJECT_TYPE_LEVEL : int { ACCESS_OBJECT_GUID = 0, ACCESS_PROPERTY_SET_GUID = 1, ACCESS_PROPERTY_GUID = 2, ACCESS_MAX_LEVEL = 4 }; enum TRUSTEE_FORM { TRUSTEE_IS_SID, TRUSTEE_IS_NAME, TRUSTEE_BAD_FORM, TRUSTEE_IS_OBJECTS_AND_SID, TRUSTEE_IS_OBJECTS_AND_NAME } enum AUTHZ_RM_FLAG : uint { AUTHZ_RM_FLAG_NO_AUDIT = 1, AUTHZ_RM_FLAG_INITIALIZE_UNDER_IMPERSONATION = 2, AUTHZ_RM_FLAG_NO_CENTRAL_ACCESS_POLICIES = 4, } enum TRUSTEE_TYPE { TRUSTEE_IS_UNKNOWN, TRUSTEE_IS_USER, TRUSTEE_IS_GROUP, TRUSTEE_IS_DOMAIN, TRUSTEE_IS_ALIAS, TRUSTEE_IS_WELL_KNOWN_GROUP, TRUSTEE_IS_DELETED, TRUSTEE_IS_INVALID, TRUSTEE_IS_COMPUTER } [DllImport("advapi32.dll", CharSet = CharSet.Auto)] static extern uint GetNamedSecurityInfo( string pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, out IntPtr pSidOwner, out IntPtr pSidGroup, out IntPtr pDacl, out IntPtr pSacl, out IntPtr pSecurityDescriptor); [DllImport("authz.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, EntryPoint = "AuthzInitializeContextFromSid", CharSet = CharSet.Unicode)] static extern public bool AuthzInitializeContextFromSid( int Flags, IntPtr UserSid, IntPtr AuthzResourceManager, IntPtr pExpirationTime, LUID Identitifier, IntPtr DynamicGroupArgs, out IntPtr pAuthzClientContext ); [DllImport("authz.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, EntryPoint = "AuthzInitializeResourceManager", CharSet = CharSet.Unicode)] static extern public bool AuthzInitializeResourceManager( int flags, IntPtr pfnAccessCheck, IntPtr pfnComputeDynamicGroups, IntPtr pfnFreeDynamicGroups, string name, out IntPtr rm ); [DllImport("authz.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, EntryPoint = "AuthzFreeResourceManager", CharSet = CharSet.Unicode)] static extern public bool AuthzFreeResourceManager(IntPtr hManager); [DllImport("authz.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, EntryPoint = "AuthzFreeHandle", CharSet = CharSet.Unicode)] static extern public bool AuthzFreeHandle(IntPtr hAccessCheckResults); [DllImport("authz.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, EntryPoint = "AuthzFreeContext", CharSet = CharSet.Unicode)] static extern public bool AuthzFreeContext(IntPtr hAuthzClientContext); [DllImport("authz.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, EntryPoint = "AuthzFreeCentralAccessPolicyCache", CharSet = CharSet.Unicode)] static extern public bool AuthzFreeCentralAccessPolicyCache(); [DllImport("authz.dll", EntryPoint = "AuthzAccessCheck", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] private static extern bool AuthzAccessCheck(int flags, IntPtr hAuthzClientContext, ref AUTHZ_ACCESS_REQUEST pRequest, IntPtr AuditEvent, IntPtr pSecurityDescriptor, byte[] OptionalSecurityDescriptorArray, int OptionalSecurityDescriptorCount, ref AUTHZ_ACCESS_REPLY pReply, out IntPtr phAccessCheckResults); enum ACCESS_MASK : uint { FILE_TRAVERSE = 0x20, FILE_LIST_DIRECTORY = 0x1, FILE_READ_DATA = 0x1, FILE_READ_ATTRIBUTES = 0x80, FILE_READ_EA = 0x8, FILE_ADD_FILE = 0x2, FILE_WRITE_DATA = 0x2, FILE_ADD_SUBDIRECTORY = 0x4, FILE_APPEND_DATA = 0x4, FILE_WRITE_ATTRIBUTES = 0x100, FILE_WRITE_EA = 0x10, FILE_DELETE_CHILD = 0x40, DELETE = 0x10000, READ_CONTROL = 0x20000, WRITE_DAC = 0x40000, WRITE_OWNER = 0x80000, ////////FILE_EXECUTE =0x20, } [Flags] enum SECURITY_INFORMATION : uint { OWNER_SECURITY_INFORMATION = 0x00000001, GROUP_SECURITY_INFORMATION = 0x00000002, DACL_SECURITY_INFORMATION = 0x00000004, SACL_SECURITY_INFORMATION = 0x00000008, UNPROTECTED_SACL_SECURITY_INFORMATION = 0x10000000, UNPROTECTED_DACL_SECURITY_INFORMATION = 0x20000000, PROTECTED_SACL_SECURITY_INFORMATION = 0x40000000, PROTECTED_DACL_SECURITY_INFORMATION = 0x80000000 } enum SE_OBJECT_TYPE { SE_UNKNOWN_OBJECT_TYPE = 0, SE_FILE_OBJECT, SE_SERVICE, SE_PRINTER, SE_REGISTRY_KEY, SE_LMSHARE, SE_KERNEL_OBJECT, SE_WINDOW_OBJECT, SE_DS_OBJECT, SE_DS_OBJECT_ALL, SE_PROVIDER_DEFINED_OBJECT, SE_WMIGUID_OBJECT, SE_REGISTRY_WOW64_32KEY } public static PermissionValues GetEffectivePermissions(string UserName, string Path, out string object_sid) { List<string> result = new List<string>(); IntPtr pSidOwner, pSidGroup, pDacl, pSacl, pSecurityDescriptor; ACCESS_MASK mask = new ACCESS_MASK(); uint ret = GetNamedSecurityInfo(Path, SE_OBJECT_TYPE.SE_FILE_OBJECT, SECURITY_INFORMATION.DACL_SECURITY_INFORMATION | SECURITY_INFORMATION.OWNER_SECURITY_INFORMATION | SECURITY_INFORMATION.GROUP_SECURITY_INFORMATION, out pSidOwner, out pSidGroup, out pDacl, out pSacl, out pSecurityDescriptor); IntPtr hManager = IntPtr.Zero; bool f = AuthzInitializeResourceManager(1, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, null, out hManager); NTAccount ac = new NTAccount(UserName); SecurityIdentifier sid; if (Imanami.PermissionProvider.FileSystem.Helper.isObjectSID(UserName)) sid = new SecurityIdentifier(UserName); else sid = (SecurityIdentifier)ac.Translate(typeof(SecurityIdentifier)); object_sid = sid.Value; byte[] bytes = new byte[sid.BinaryLength]; sid.GetBinaryForm(bytes, 0); String _psUserSid = ""; foreach (byte si in bytes) { _psUserSid += si; } LUID unusedSid = new LUID(); IntPtr UserSid = Marshal.AllocHGlobal(bytes.Length); Marshal.Copy(bytes, 0, UserSid, bytes.Length); IntPtr pClientContext = IntPtr.Zero; if (f) { f = AuthzInitializeContextFromSid(0, UserSid, hManager, IntPtr.Zero, unusedSid, IntPtr.Zero, out pClientContext); AUTHZ_ACCESS_REQUEST request = new AUTHZ_ACCESS_REQUEST(); request.DesiredAccess = 0x02000000; request.PrincipalSelfSid = null; request.ObjectTypeList = null; request.ObjectTypeListLength = 0; request.OptionalArguments = IntPtr.Zero; AUTHZ_ACCESS_REPLY reply = new AUTHZ_ACCESS_REPLY(); reply.GrantedAccessMask = IntPtr.Zero; reply.ResultListLength = 0; reply.SaclEvaluationResults = IntPtr.Zero; IntPtr AccessReply = IntPtr.Zero; reply.Error = Marshal.AllocHGlobal(1020); reply.GrantedAccessMask = Marshal.AllocHGlobal(sizeof(uint)); reply.ResultListLength = 1; int i = 0; Dictionary<String, String> rightsmap = new Dictionary<String, String>(); List<string> effectivePermissionList = new List<string>(); string[] rights = new string[14] { "Full Control", "Traverse Folder / execute file", "List folder / read data", "Read attributes", "Read extended attributes", "Create files / write files", "Create folders / append data", "Write attributes", "Write extended attributes", "Delete subfolders and files", "Delete", "Read permission", "Change permission", "Take ownership" }; rightsmap.Add("FILE_TRAVERSE", "Traverse Folder / execute file"); rightsmap.Add("FILE_LIST_DIRECTORY", "List folder / read data"); rightsmap.Add("FILE_READ_DATA", "List folder / read data"); rightsmap.Add("FILE_READ_ATTRIBUTES", "Read attributes"); rightsmap.Add("FILE_READ_EA", "Read extended attributes"); rightsmap.Add("FILE_ADD_FILE", "Create files / write files"); rightsmap.Add("FILE_WRITE_DATA", "Create files / write files"); rightsmap.Add("FILE_ADD_SUBDIRECTORY", "Create folders / append data"); rightsmap.Add("FILE_APPEND_DATA", "Create folders / append data"); rightsmap.Add("FILE_WRITE_ATTRIBUTES", "Write attributes"); rightsmap.Add("FILE_WRITE_EA", "Write extended attributes"); rightsmap.Add("FILE_DELETE_CHILD", "Delete subfolders and files"); rightsmap.Add("DELETE", "Delete"); rightsmap.Add("READ_CONTROL", "Read permission"); rightsmap.Add("WRITE_DAC", "Change permission"); rightsmap.Add("WRITE_OWNER", "Take ownership"); f = AuthzAccessCheck(0, pClientContext, ref request, IntPtr.Zero, pSecurityDescriptor, null, 0, ref reply, out AccessReply); if (f) { int granted_access = Marshal.ReadInt32(reply.GrantedAccessMask); mask = (ACCESS_MASK)granted_access; foreach (ACCESS_MASK item in Enum.GetValues(typeof(ACCESS_MASK))) { if ((mask & item) == item) { effectivePermissionList.Add(rightsmap[item.ToString()]); i++; } } } //Clear Memory { Marshal.FreeHGlobal(reply.GrantedAccessMask); if (reply.Error != IntPtr.Zero) Marshal.FreeHGlobal(reply.Error); if (UserSid != IntPtr.Zero) Marshal.FreeHGlobal(UserSid); if (pSidOwner != IntPtr.Zero) Marshal.Release(pSidOwner); if (pSidGroup != IntPtr.Zero) Marshal.Release(pSidGroup); if (pDacl != IntPtr.Zero) Marshal.Release(pDacl); if (pSacl != IntPtr.Zero) Marshal.Release(pSacl); if (pSecurityDescriptor != IntPtr.Zero) Marshal.Release(pSecurityDescriptor); if (reply.SaclEvaluationResults != IntPtr.Zero) Marshal.FinalReleaseComObject(reply.SaclEvaluationResults); if (request.OptionalArguments != IntPtr.Zero) Marshal.FinalReleaseComObject(request.OptionalArguments); bool flag = false; if (AccessReply != IntPtr.Zero) flag = AuthzFreeHandle(AccessReply); if (hManager != IntPtr.Zero) flag = AuthzFreeResourceManager(hManager); if (pClientContext != IntPtr.Zero) flag = AuthzFreeContext(pClientContext); AuthzFreeCentralAccessPolicyCache(); } if (i == 16) { effectivePermissionList.Insert(0, "Full Control"); return PermissionValues.FULL_CONTROL; } PermissionValues per = PermissionValues.NONE; foreach (string r in effectivePermissionList) { switch (r) { case "Traverse Folder / execute file": per |= PermissionValues.FILE_TRAVERSE; break; case "List folder / read data": per |= PermissionValues.FILE_LIST_DIRECTORY; break; case "Read attributes": per |= PermissionValues.FILE_READ_ATTRIBUTES; break; case "Read extended attributes": per |= PermissionValues.FILE_READ_EA; break; case "Create files / write files": per |= PermissionValues.FILE_ADD_FILE; break; case "Create files / write files": per |= PermissionValues.FILE_WRITE_DATA; break; case "Create folders / append data": per |= (PermissionValues.FILE_ADD_SUBDIRECTORY | PermissionValues.FILE_APPEND_DATA); break; case "Write attributes": per |= PermissionValues.FILE_WRITE_ATTRIBUTES; break; case "Write extended attributes": per |= PermissionValues.FILE_WRITE_EA; break; case "Delete subfolders and files": per |= PermissionValues.FILE_DELETE_CHILD; break; case "Delete": per |= PermissionValues.DELETE; break; case "Read permission": per |= PermissionValues.READ_CONTROL; break; case "Change permission": per |= PermissionValues.WRITE_DAC; break; case "Take ownership": per |= PermissionValues.WRITE_OWNER; break; } } return per; } return PermissionValues.NONE; } } }
System.ApplicationException: The requested site does not appear to have claims enabled or the Login Url has not been set.
at SharePointPlugin.ClaimsWebAuth.Show()
sometime it works and sometimes it gives above error, I am not getting why it works for some time and sometime fails.
In single day it worked in morning and failed in noon, something strange ?
Any help?
Hi,
Following errors appear, while attempting to post the data to the stateful services developed in ASP.NetCore 2.1
{"Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":
"System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}
Ajay
In my C# project, while a UDP packet arriving, I need to log a timestamp with microsecond value.
Below is a sample function to use microsecond timestamp:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace datetimetest { class Program { static void Main(string[] args) { for(int i=0;i<10;i++) { long currentTick = DateTime.Now.Ticks; Console.WriteLine("currentTick:{0}; timestamp:{1}", currentTick, new DateTime(currentTick).ToString("HH:mm:ss.ffffff")); } Console.ReadLine(); } } }
I got below result:
currentTick:636844467783194613;timestamp:12:06:18.319461 currentTick:636844467783204613;timestamp:12:06:18.320461 currentTick:636844467783214613;timestamp:12:06:18.321461 currentTick:636844467783214613;timestamp:12:06:18.321461 currentTick:636844467783214613;timestamp:12:06:18.321461 currentTick:636844467783214613;timestamp:12:06:18.321461 currentTick:636844467783214613;timestamp:12:06:18.321461 currentTick:636844467783214613;timestamp:12:06:18.321461 currentTick:636844467783214613;timestamp:12:06:18.321461 currentTick:636844467783214613;timestamp:12:06:18.321461
My questions are:
1. On some PCs, the last 4 numbers would never change. In above case, the last 4 numbers are always "4613". Why?
2. Is there any better way to get the timestamp with microsecond value?
Any comments are highly appreciated.
I have a method that enumerates files in a directory and copies them to another directory.
//source is a DirectoryInfo object
// target is also a DirectoryInfo object.
foreach (FileInfo fi in source.GetFiles())
{
var TargetFile = (Path.Combine(target.ToString(), fi.Name));
try
{
var attr = FileAttributes.Normal;
if (File.Exists(TargetFile))
{
attr = File.GetAttributes(TargetFile);
File.SetAttributes(TargetFile, FileAttributes.Normal);
}
fi.CopyTo(TargetFile, true);
File.SetAttributes(TargetFile, attr);
}
catch (Exception ex)
{
Log.Write(ex.Message);
}
}
The behaviour I am experiencing is that one of the subdirectories is being recognised as a file and the routine creates a file with the name of the subdirectory. Has anyone come across this before and know why it is happening?
Thanks
So I have some tutorial files for a game that I am making. The serialized file contains an enum who's name I was forced to change to avoid a naming conflict inside the Unity game engine. Making these tutorial files was labor intensive and I can't remake them.
The file contains a 2D array of class MapCell, and each MapCell contains a field of type Halo.Halotypes. The word 'Halo' now has a different meaning inside the Unity game engine and I can't use that as a class name anymore. I need to change the class name to 'RangeHalo'.
The SaveFile class and the MapCell class have the [Serializable] attribute, and I use BinaryFormatter to save and load.
How can I load the file with the old name and then save it with the new name? Making a new version of Halo will have wide impact across all my code, but renaming Halo to RangeHalo breaks my tutorial files.
I need to save these files, every way I can thing to do it is a nightmare. I need help.
Scenario : Lets say i have a treeView that has 1000 nodes in which User has selected 10 checkboxes and clicked save and refreshes the page. It will trigger a backend logic that will save his checkbox changes to the DB.
Now User 2 will go to the same treeview and unchecks 5 checkboxes and save it . How do i capture these 5 uncheck boxes treenode in the backend .
For example if the checkbox is checked what we can do is loop through TreeView1.CheckedNodes which captures all the 10 checkboxes that User1 clicked.
Expectations : Way to figure out how to capture the unchecked checkboxes node which User 2 UnChecked on postback call. i.e 5
I have deleted PagedList package from References while it is still in Package.config and when I reinstall it it dose not show in References any more
Also I try to restore NUGET package but I don't have the option of Enable Restore NUGET package
What should I do to restore this specific packages
Hi
i have an application which runs in asp.net core angular framework hosted in iis with windows authentication
need all active directory details when any user login to the application with windows authentication
i tried different ways but i'm getting appool username instead of login user name
pls help on this
We've got .NET UWP app running on a HP Engage One AiO System Model 143. The unit has a customer facing front 2x20 screen which we don't know how to utilize. Would the LineDisplay Class from the POS for .NET be the way to do this and can this API be used within a UDP app written in VS2017 C#?
TIA
Harry
Is the POS for .Net incorporated into the Windows 10 IoT 2016 LTSB 64-bit?
Or is the POS for .Net replaced or outdated? Can the classes such as the LineDisplay class be called from within .NET UWP app?
What are the current plans for improving the support for the decimal datatype (such as adding missing functions to System.Math)?
We are using decimal to store financial information and will probably use it to perform some calculations, but not beeing able to use exp,log etc without casting back and forth to double etc makes things a lot less straightforward than it should be.
I found the following feedback on this from 2004 and 2006, but surley you must be able to improve it now after 6-8 years?
* A (still open) feature requst for VS 2005 that was to be looked into after VS 2005 release: https://connect.microsoft.com/VisualStudio/feedback/details/94548/math-pow-method-should-have-an-overload-for-decimal
* A thread from back in 2006 (http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/753b6659-4a8a-4389-b805-126ae670aba9/) it was stated that Math.Sqrt was not supported since MSVCRT did only support 64bit floating points, but maybe there are some of the missing functions that can be added more efficiently today than in 2006?
Update with some further results on the topic of decimal support:
* In 2008 the IEEE 754 introduced among other things decimal128 (see
http://en.wikipedia.org/wiki/IEEE_754-2008).
* Support for the different decimal datatypes are beeing standardized in a techincal report for c (http://www.open-std.org/jtc1/sc22/wg14/www/projects#24732) and c++ (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2849.pdf) and these both include math functions with enought precision also there are several request for MSSQL to support the new types in the next release, and at least they "should look into it" so if you don't have the required code base yet you should be able to get someone start working on decimal128 support which in the end hopfully can provide us with richer functionality for system.decimal (and maybe even an implementation for decimal128 in .net with at least theoretical hardware support :) ).
* Decimal support can also be optained from intel http://software.intel.com/en-us/articles/intel-decimal-floating-point-math-library/
/Daniel Svensson
Hello everyone
i don't know if this forum is right place to write my question or not.
i create app on my pc to send and receive data using udp protocol. i use code to monitor data recieving on my server and i found some data lossing when sending from my pc.
I'm trying to solve this issue for long time but i fall
my pc internet connection is fiper optic download (60 Mbps) upload (15Mbps)
Can anyone help me to fix this problem and save my time, please?
these are codes that i use on my pc
code of sending:
public async Task LinesAsPara(LineCollection Lines) { CancelTask = false; taskToken = new CancellationTokenSource(); CancellationToken ct = taskToken.Token; if (Monitor.IsEntered(syncObj)) { paused = false; Monitor.Exit(syncObj); } WatchTest.Start(); Task task = new Task(() => { foreach (var Oneline in ltlTextArea.TextArea.Lines) { try { CheckForIllegalCrossThreadCalls = false; string pattern = @"(?:CACHE PEER|cache peer):\s*(\S+)+\s+(\d*)"; foreach (Match m in Regex.Matches(Oneline.Text, pattern)) { Server = Dns.GetHostAddresses(m.Groups[1].Value)[0]; RemotePort = Convert.ToInt32(m.Groups[2].Value); CachePeer = m.Groups[0].Value; } IPEndPoint ipeSender = new IPEndPoint(Server, RemotePort); //The epSender identifies the incoming clients EndPoint epSender = (EndPoint)ipeSender; int ID = 0; byte[] buf = new byte[32]; buf[0] = TYPE_PINGREQ; // Self Program Use buf[1] = 0x4D; buf[2] = 0x43; buf[3] = 0; // ping packet number buf[4] = (byte)(Oneline.Index >> 8); buf[5] = (byte)(Oneline.Index & 0xff); // Multics Identification buf[6] = (byte)ID; // unused must be zero (for next use) buf[7] = (byte)('M' ^ buf[1] ^ buf[2] ^ buf[3] ^ buf[4] ^ buf[5] ^ buf[6]); // Multics Checksum buf[8] = (byte)'M'; // Multics ID //Port buf[9] = 0; buf[10] = 0; buf[11] = (byte)((int)CachePort.Value >> 8); buf[12] = (byte)((int)CachePort.Value & 0xff); //Program buf[13] = 0x01; //ID buf[14] = 7; //LEN buf[15] = (byte)'M'; buf[16] = (byte)'u'; buf[17] = (byte)'l'; buf[18] = (byte)'t'; buf[19] = (byte)'i'; buf[20] = (byte)'C'; buf[21] = (byte)'S'; //Version buf[22] = 0x02; //ID // if (REVISION<100) { buf[23] = 3; //LEN buf[24] = (byte)'r'; int REVISION = 81; buf[25] = (byte)('0' + (REVISION / 10)); buf[26] = (byte)('0' + (REVISION % 10)); MainCSP CSPPeer = new MainCSP { //CachePort = (int)CachePort.Value, MSec = Oneline.Index, CachePeer = CachePeer }; PeerList.Add(CSPPeer); serverSocket.BeginSendTo(buf, 0, buf.Length, SocketFlags.None, epSender, new AsyncCallback(OnSend), null); sendDone.WaitOne(); } catch (Exception ex) { MessageBox.Show(ex.Message, "SGSServerUDP1", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }); task.Start(); WatchTest.Stop(); ShowWatch.Stop(); StopwatchBut.Text = string.Format("{0}D {1}h : {2}m : {3}.{4}s", WatchTest.Elapsed.Days, WatchTest.Elapsed.Hours, WatchTest.Elapsed.Minutes, WatchTest.Elapsed.Seconds, WatchTest.Elapsed.Milliseconds); Form1.IsVoice = SpeakerSwitch.Value; VoiceButtonItem.PerformClick(); DesktopAlert.Show(); DesktopAlert.CaptionText = string.Format("Lines Tester (ID:{0})", Form1.SessionID); DesktopAlert.ContentText = string.Format("The test is completed." + Environment.NewLine + "||Working({0})||Syntax({1})||Other({2})||", WorkBtn.Counter.Text, SyntaxBtn.Counter.Text, OtherBtn.Counter.Text); ltlStartButton.Enabled = true; } public void OnSend(IAsyncResult ar) { try { serverSocket.EndSend(ar); sendDone.Set(); } catch (Exception ex) { MessageBox.Show(ex.Message, "SGSServerUDP2", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
code of recieving:
void Receive() { try { CheckForIllegalCrossThreadCalls = false; //We are using UDP sockets serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //Assign the any IP of the machine and listen on port number 1000 IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, (int)CachePort.Value); //Bind this address to the server serverSocket.Bind(ipEndPoint); IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0); //The epSender identifies the incoming clients EndPoint epSender = (EndPoint)ipeSender; //Start receiving data serverSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender, new AsyncCallback(OnReceive), epSender); } catch (Exception ex) { MessageBox.Show(ex.Message, "SGSServerUDP3", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void OnReceive(IAsyncResult ar) { try { IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0); EndPoint epSender = (EndPoint)ipeSender; serverSocket.EndReceiveFrom(ar, ref epSender); const int TYPE_PINGRPL = 4; switch (byteData[0]) { case TYPE_PINGRPL: int result = PeerList.FindIndex(x => x.MSec == ((byteData[4] << 8) | byteData[5])); if (result != -1) { WorkBtn.AddData(PeerList[result].CachePeer + "(" + ((byteData[4] << 8) | byteData[5]) + ")" + Environment.NewLine); DesktopAlert.ContentText = string.Format("The test is completed." + Environment.NewLine + "||Working({0})||Syntax({1})||Other({2})||", WorkBtn.Counter.Text, SyntaxBtn.Counter.Text, OtherBtn.Counter.Text); PeerList.RemoveAt(result); } break; } serverSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender, new AsyncCallback(OnReceive), epSender); } catch (Exception ex) { MessageBox.Show(ex.Message, "SGSServerUDP4", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
Thank you
GDI+ experts, I beseech your advice.
I have created an image processing application in C# that deals entirely with 16-bpp GrayScale images. Currently I'm handling a few simple file formats (proprietary) that have a header followed by the pixel values (in each case, as unsigned words (ushort)). I store the pixels in an array ushort[width, height] and I apply all my filters to this array, then I call a static method to redraw the displayed image in a picturebox (in 8-bit grayscale form). I need the 16bpp values - I allow the user to stretch contrast over a smaller range of pixel values so they can see more of the dynamic range.
I've recently learned that I need to handle TIFF images, also 16bpp. Some of these files are multi-frame. What course of action would you recommend? I would like to separate the frames as individual TIFF files, then use the header information in the TIFF to get the width and height of the image, then extract the pixel data to a ushort[width,height]. That way I won't need to change any of my existing image processing code.
Is this even going to be possible? Are there existing libraries written for this purpose that are widely available? I've exhausted google.
I have created a datagrid view i want to filter its data according to date ranges between 2 DateTimePicker I am not able to create a row filter for the dataview which i am assigning to the datagrid as source.
My database formate of that column is
TO_CHAR(a.ord_order_time, 'DD-MM-YY HH:MI') as "Order_Time",
and in coding
filter = string.Format("Order_Time >= {0:dd-MM-yy HH:MM } AND Order_Time < {1:dd-MM-yy HH:MM }", dtpFrom.Value, dtpTo.Value);
using above code for the filter it will give me exceptions .
Plz provide me appropriate code snippets to create rowfilter regarding dateRange
SaiVaibhav@Acumen
Hello everyone
i don't know if this forum is right place to write my question or not.
i create app on my pc to send and receive data using udp protocol. i use code to monitor data recieving on my server and i found some data lossing when sending from my pc.
I'm trying to solve this issue for long time but i fall
my pc internet connection is fiper optic download (60 Mbps) upload (15Mbps)
Can anyone help me to fix this problem and save my time, please?
these are codes that i use on my pc
code of sending:
public async Task LinesAsPara(LineCollection Lines) { CancelTask = false; taskToken = new CancellationTokenSource(); CancellationToken ct = taskToken.Token; if (Monitor.IsEntered(syncObj)) { paused = false; Monitor.Exit(syncObj); } WatchTest.Start(); Task task = new Task(() => { foreach (var Oneline in ltlTextArea.TextArea.Lines) { try { CheckForIllegalCrossThreadCalls = false; string pattern = @"(?:CACHE PEER|cache peer):\s*(\S+)+\s+(\d*)"; foreach (Match m in Regex.Matches(Oneline.Text, pattern)) { Server = Dns.GetHostAddresses(m.Groups[1].Value)[0]; RemotePort = Convert.ToInt32(m.Groups[2].Value); CachePeer = m.Groups[0].Value; } IPEndPoint ipeSender = new IPEndPoint(Server, RemotePort); //The epSender identifies the incoming clients EndPoint epSender = (EndPoint)ipeSender; int ID = 0; byte[] buf = new byte[32]; buf[0] = TYPE_PINGREQ; // Self Program Use buf[1] = 0x4D; buf[2] = 0x43; buf[3] = 0; // ping packet number buf[4] = (byte)(Oneline.Index >> 8); buf[5] = (byte)(Oneline.Index & 0xff); // Multics Identification buf[6] = (byte)ID; // unused must be zero (for next use) buf[7] = (byte)('M' ^ buf[1] ^ buf[2] ^ buf[3] ^ buf[4] ^ buf[5] ^ buf[6]); // Multics Checksum buf[8] = (byte)'M'; // Multics ID //Port buf[9] = 0; buf[10] = 0; buf[11] = (byte)((int)CachePort.Value >> 8); buf[12] = (byte)((int)CachePort.Value & 0xff); //Program buf[13] = 0x01; //ID buf[14] = 7; //LEN buf[15] = (byte)'M'; buf[16] = (byte)'u'; buf[17] = (byte)'l'; buf[18] = (byte)'t'; buf[19] = (byte)'i'; buf[20] = (byte)'C'; buf[21] = (byte)'S'; //Version buf[22] = 0x02; //ID // if (REVISION<100) { buf[23] = 3; //LEN buf[24] = (byte)'r'; int REVISION = 81; buf[25] = (byte)('0' + (REVISION / 10)); buf[26] = (byte)('0' + (REVISION % 10)); MainCSP CSPPeer = new MainCSP { //CachePort = (int)CachePort.Value, MSec = Oneline.Index, CachePeer = CachePeer }; PeerList.Add(CSPPeer); serverSocket.BeginSendTo(buf, 0, buf.Length, SocketFlags.None, epSender, new AsyncCallback(OnSend), null); sendDone.WaitOne(); } catch (Exception ex) { MessageBox.Show(ex.Message, "SGSServerUDP1", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }); task.Start(); WatchTest.Stop(); ShowWatch.Stop(); StopwatchBut.Text = string.Format("{0}D {1}h : {2}m : {3}.{4}s", WatchTest.Elapsed.Days, WatchTest.Elapsed.Hours, WatchTest.Elapsed.Minutes, WatchTest.Elapsed.Seconds, WatchTest.Elapsed.Milliseconds); Form1.IsVoice = SpeakerSwitch.Value; VoiceButtonItem.PerformClick(); DesktopAlert.Show(); DesktopAlert.CaptionText = string.Format("Lines Tester (ID:{0})", Form1.SessionID); DesktopAlert.ContentText = string.Format("The test is completed." + Environment.NewLine + "||Working({0})||Syntax({1})||Other({2})||", WorkBtn.Counter.Text, SyntaxBtn.Counter.Text, OtherBtn.Counter.Text); ltlStartButton.Enabled = true; } public void OnSend(IAsyncResult ar) { try { serverSocket.EndSend(ar); sendDone.Set(); } catch (Exception ex) { MessageBox.Show(ex.Message, "SGSServerUDP2", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
code of recieving:
void Receive() { try { CheckForIllegalCrossThreadCalls = false; //We are using UDP sockets serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //Assign the any IP of the machine and listen on port number 1000 IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, (int)CachePort.Value); //Bind this address to the server serverSocket.Bind(ipEndPoint); IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0); //The epSender identifies the incoming clients EndPoint epSender = (EndPoint)ipeSender; //Start receiving data serverSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender, new AsyncCallback(OnReceive), epSender); } catch (Exception ex) { MessageBox.Show(ex.Message, "SGSServerUDP3", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void OnReceive(IAsyncResult ar) { try { IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0); EndPoint epSender = (EndPoint)ipeSender; serverSocket.EndReceiveFrom(ar, ref epSender); const int TYPE_PINGRPL = 4; switch (byteData[0]) { case TYPE_PINGRPL: int result = PeerList.FindIndex(x => x.MSec == ((byteData[4] << 8) | byteData[5])); if (result != -1) { WorkBtn.AddData(PeerList[result].CachePeer + "(" + ((byteData[4] << 8) | byteData[5]) + ")" + Environment.NewLine); DesktopAlert.ContentText = string.Format("The test is completed." + Environment.NewLine + "||Working({0})||Syntax({1})||Other({2})||", WorkBtn.Counter.Text, SyntaxBtn.Counter.Text, OtherBtn.Counter.Text); PeerList.RemoveAt(result); } break; } serverSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender, new AsyncCallback(OnReceive), epSender); } catch (Exception ex) { MessageBox.Show(ex.Message, "SGSServerUDP4", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
Thank you
Hi,
We are unable to add and download word file. Same below code is working while i am running from visual studio, but this same code not working from IIS web server. This below Add document code failing when i am running from IIS, not able to adddocument from path.
document = application.Documents.Add(Template: path);
Please check the below source code
application.Documents.Add was causing issue, please check the below source code
application =newMicrosoft.Office.Interop.Word.Application();
document =newMicrosoft.Office.Interop.Word.Document();string path =string.Format("{0}{1}{2}",System.Web.Configuration.WebConfigurationManager.AppSettings.Get("InputFilePath").ToString(), docname,ConfigurationManager.AppSettings["FileExtention"].ToString());
document = application.Documents.Add(Template: path);
application.Visible=true;
document.SaveAs(FileName:string.Format("{0}{1}",System.Web.Configuration.WebConfigurationManager.AppSettings["OutputFilePath"].ToString(), unqnum));
document.Close();
application.Quit();Response.ContentType="application/octet-stream";Response.AppendHeader("Content-Disposition","attachment; filename="+ unqnum);Response.TransmitFile(destpath);Response.End();
Error: Word was unable to read this document. It may be corrupt. Try one or more of the following: * Open and Repair the file. * Open the file with the Text Recovery converter.
Thanks for you help
Ashis
hi all,
my company is developing an application which have the ability to preview excel files using: IPreviewHandler interface.
when it is used with office 2010, we didn't have any problems but when we used it with office 2016, especially excel, we started to see cpu high usage and the only way to solve it is to kill excel.
my developer said that the following exception is issued before excel.exe*32 hangs and uses 50% cpu:
i found links that says there is a bug with some KB but i do not see them installed.
does anyone has an idea ?
Udi