Search Results

Search found 4077 results on 164 pages for 'throw'.

Page 49/164 | < Previous Page | 45 46 47 48 49 50 51 52 53 54 55 56  | Next Page >

  • IEnumerable<T> ToArray usage, is it a copy or a pointer?

    - by Daniel
    I am parsing an arbitrary length byte array that is going to be passed around to a few different layers of parsing. Each parser creates a Header and a Packet payload just like any ordinary encapsulation. And my problem lies in how the encapsulation holds its packet byte array payload. Say i have a 100 byte array, and it has 3 levels of encapsulation. 3 packet objects will be created and i want to set the payload of these packets to the corresponding position in the byte array of the packet. For example lets say the payload size is 20 for all levels, then imagine it has a public byte[] Payload on each object. However the problem is that this byte[] Payload is a copy of the original 100 bytes. So i'm going to end up with 160 bytes in memory instead of 100. If it were in c++ i could just easily use a pointer however i'm writing this in c#. So i created the following class: public class PayloadSegment<T> : IEnumerable<T> { public readonly T[] Array; public readonly int Offset; public readonly int Count; public PayloadSegment(T[] array, int offset, int count) { this.Array = array; this.Offset = offset; this.Count = count; } public T this[int index] { get { if (index < 0 || index >= this.Count) throw new IndexOutOfRangeException(); else return Array[Offset + index]; } set { if (index < 0 || index >= this.Count) throw new IndexOutOfRangeException(); else Array[Offset + index] = value; } } public IEnumerator<T> GetEnumerator() { for (int i = Offset; i < Offset + Count; i++) yield return Array[i]; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { IEnumerator<T> enumerator = this.GetEnumerator(); while (enumerator.MoveNext()) { yield return enumerator.Current; } } } This way i can simply reference a position inside the original byte array but use positional indexing. However if i do something like: PayloadSegment<byte> something = new PayloadSegment<byte>(someArray, 5, 10); byte[] somethingArray = something.ToArray(); Will the somethingArray be a copy of the bytes, or a reference to the original PayloadSegment which in turn is a reference to the original byte array? Sorry it was hard to word this lol _<

    Read the article

  • Whats a good API for generating reports for a java web application?

    - by Ahmad
    I have a J2EE application that has a lot of reports, the situation now is the following: Report filters' values are sent to the application over DWR mainly, the data are retrieved from Oracle DB throw DB procedures and returned back to the client. However, some customization is required every now and then (new data filters, columns, ordering, ...), and these changes are painful to implement since we need to modify the JSPs, DB Procedures, the application itself, ... What API do you recommend to use for such reports?

    Read the article

  • Http web request doesn't maintaining session.

    - by Pankaj Mishra
    Hello, I have program where i want to scrap some Useful study material for me. This site site maintaining session key and some other key also. If I trying to go nested page then it will throw me out and showing session out message. I unable to maintaining session key in web request class. so please give me some idea that how can i maintain session in web request class.

    Read the article

  • Cannot render javascript from controller

    - by Ermin
    I want to display a modal window with an error message, when the user has entered something invalid in a form, but render another action if everything is ok. However, when I try to display the modal window with render :js => "jQuery.facebox(#{...})" only the actual javascript called is displayed: try { jQuery.facebox(...) } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('jQuery.facebox(\"<div class=\'error\'>Error</div>\")'); throw e }

    Read the article

  • stop thread that does not get interrupted

    - by prmatta
    I have a thread that sits and reads objects off of an ObjectInputStream: public void run() { try { ois = new ObjectInputStream(clientSocket.getInputStream()); Object o; while ((o = ois.readObject()) != null) { //do something with object } } catch (Exception ex) { //Log exception } } readObject does not throw InterruptedException and as far as I can tell, no exception is thrown when this thread is interrupted. How do I stop this thread?

    Read the article

  • GORM "getNextException" equivalent

    - by Josh K
    GORM sits on top of [Hibernate](http://en.wikipedia.org/wiki/Hibernate_(Java). The issue is that sometimes Hibernate will throw exceptions from the JDBC driver that I can't figure out how to investigate. Specifically: Could not execute JDBC batch update; /* snip */ Caused by: java.sql.BatchUpdateException: /* snip */ [insert] was aborted. Call getNextException to see the cause. If it makes any difference I'm using PostgreSQL.

    Read the article

  • Zend Framework Routing: .html extension

    - by smack0007
    I know I've seen this done before but I can't find the information anywhere. I need to be able to route with .html extensions in the Zend Framework. I.E. /controller/action.html should route to the appropriate controller / action. We have an idea to throw away the .html extension with our .htaccess file but I think changing the route config would be the better solution. Any advice is welcome.

    Read the article

  • DUMP in unhandled C++ exception

    - by Jorge Vasquez
    In MSVC, how can I make any unhandled C++ exception (std::runtime_error, for instance) crash my release-compiled program so that it generates a dump with the full stack from the exception throw location? I have installed NTSD in the AeDebug registry an can generate good dumps for things like memory access violation, so the matter here comes down to crashing the program correctly, I suppose. Thanks in advance.

    Read the article

  • Ad-hoc retreival of data from SQL Server varbinary column

    - by Daniel Fortunov
    I would like to retreive some binary data from a varbinary(max) column in a SQL Server database for debugging purposes. What is the easiest way to get this data into a local binary file, preferably without having to write a throw-away console application? I have tried using SQL Server Management Studio but this returns a hex encoded binary string, rather than raw binary data (even with the "results to file" option).

    Read the article

  • what concepts every .NET developer should understand?

    - by EquinoX
    Please throw in the core concepts of what every .NET developer should know about? I am asking here about concepts specific to .NET and not web developer in general... Maybe concepts that are most likely to be asked in interview? As a general web developer, javascript and css are definitely a must. Share your ideas here guys

    Read the article

  • FluentNHibernate - AutoMappings producing incorrect one-to-many column key

    - by Alberto
    Hi I'm new to NHibernate and FNH and am trying to map these simple classes by using FluentNHibernate AutoMappings feature: public class TVShow : Entity { public virtual string Title { get; set;} public virtual ICollection<Season> Seasons { get; protected set; } public TVShow() { Seasons = new HashedSet<Season>(); } public virtual void AddSeason(Season season) { season.TVShow = this; Seasons.Add(season); } public virtual void RemoveSeason(Season season) { if (!Seasons.Contains(season)) { throw new InvalidOperationException("This TV Show does not contain the given season"); } season.TVShow = null; Seasons.Remove(season); } } public class Season : Entity { public virtual TVShow TVShow { get; set; } public virtual int Number { get; set; } public virtual IList<Episode> Episodes { get; set; } public Season() { Episodes = new List<Episode>(); } public virtual void AddEpisode(Episode episode) { episode.Season = this; Episodes.Add(episode); } public virtual void RemoveEpisode(Episode episode) { if (!Episodes.Contains(episode)) { throw new InvalidOperationException("Episode not found on this season"); } episode.Season = null; Episodes.Remove(episode); } } I'm also using a couple of conventions: public class MyForeignKeyConvention : IReferenceConvention { #region IConvention<IManyToOneInspector,IManyToOneInstance> Members public void Apply(FluentNHibernate.Conventions.Instances.IManyToOneInstance instance) { instance.Column("fk_" + instance.Property.Name); } #endregion } The problem is that FNH is generating the section below for the Seasons property mapping: <bag name="Seasons"> <key> <column name="TVShow_Id" /> </key> <one-to-many class="TVShowsManager.Domain.Season, TVShowsManager.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> </bag> The column name above should be fk_TVShow rather than TVShow_Id. If amend the hbm files produced by FNH then the code works. Does anyone know what it's wrong? Thanks in advance.

    Read the article

  • jQuery grab html

    - by Happy
    We have link to some page (with html code, on the same domain), that page have one img, which attributes title and alt are equal. Script must open link (no showing on the page), grab the src attribute of img which title=alt, and throw the value into some variable. Is it possible to do? Thanks.

    Read the article

  • send mail by using php5

    - by rajson
    hi friends, i wish to send form data throw mailto() in php, but i got an warning msg that "Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\ please sugest me that what i have to do for send data to a mail id properly

    Read the article

  • Using Flex Builder with source control

    - by Dan Monego
    When setting up a source control repository for a Flex Builder workspace, what do you consider to be worth checking in? Do you exclude the workspace .metadata folder but keep the .project and other project specific files? Keep both? Throw away both? Is there a guideline you use to decide which is worth holding onto or do you do it out of practical experience?

    Read the article

  • How to validate Login Details using Google apps API ?

    - by Pari
    Hi, I am using below code to to create Contact Service and to Validate login Details: ContactsService obj_ContactService = new ContactsService(""); obj_ContactService.setUserCredentials(userEmail, password); But even if user enters invalid detail above code does not throw any exception. User get verified only when i call "Insert" query after adding whole contact details. But in my application i want to notify user immediately after user enters login details. Thanx

    Read the article

  • How to adjust microphone gain from C# (needs to work on XP & W7)...

    - by Ed
    First, note that I know there are a few questions like this already posted; however they don't seem to address the problem adequately. I have a C# application, with all the pInvoke hooks to talk to the waveXXX API, and I'm able to do capture and play back of audio with that. I'm also able to adjust speaker (WaveOut) volume with that API. The problem is that for whatever reason, that API does not allow me to adjust microphone (WaveIn) volume. So, I managed to find some mixer code that I've also pulled in and access through pInvoke and that allows me to adjust microphone volume, but only on my W7 PC. The mixer code I started with comes from here: http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/05dc2d35-1d45-4837-8e16-562ee919da85 and it works, but is written to adjust speaker volume. I added the SetMicVolume method shown here... public static void SetMicVolume(int mxid, int percentage) { bool rc; int mixer, vVolume; MIXERCONTROL volCtrl = new MIXERCONTROL(); int currentVol; mixerOpen(out mixer, mxid, 0, 0, MIXER_OBJECTF_WAVEIN); int type = MIXERCONTROL_CONTROLTYPE_VOLUME; rc = GetVolumeControl(mixer, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, type, out volCtrl, out currentVol); if (rc == false) { mixerClose(mixer); mixerOpen(out mixer, 0, 0, 0, 0); rc = GetVolumeControl(mixer, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, type, out volCtrl, out currentVol); if (rc == false) throw new Exception("SetMicVolume/GetVolumeControl() failed"); } vVolume = ((int)((float)(volCtrl.lMaximum - volCtrl.lMinimum) / 100.0F) * percentage); rc = SetVolumeControl(mixer, volCtrl, vVolume); if (rc == false) throw new Exception("SetMicVolume/SetVolumeControl() failed"); mixerClose(mixer); } Note the "second attempt" to call GetVolumeControl(). This is done because on XP, in the first call to GetVolumeControl (refer to site above for that code), the call to mixerGetLineControlsA() fails with XP systems returning MIXERR_INVALCONTROL. Then, with this second attempt using mixerOpen(out mixer, 0, 0, 0, 0), the code doesn't return a failure but the mic gain is unaffected. Note, as I said above, this works on W7 (the second attempt is never executed because it doesn't fail using mixerOpen(out mixer, mxid, 0, 0, MIXER_OBJECTF_WAVEIN)). I admit to not having a good grasp on the mixer API, so that's what I'm looking into now; however if anyone has a clue why this would work on W7, but not XP, I'd sure like to hear it. Meanwhile, if I figure it out before I get a response, I'll post my own answer...

    Read the article

  • ScheduledExecutorService throwable lost

    - by Andrey
    Hello, Consider I scheduled a Runnable for periodic execution with ScheduledExecutorService and there occurs some system Error like OutOfMemory. It will be silently swallowed. scheduler.scheduleWithFixedDelay(new Runnable() { @Override public void run() { throw new OutOfMemoryError(); // Swallowed } }, 0, delay, TimeUnit.SECONDS); Is it normal? Why doesn't it propagate to the container? What is the correct way to handle such errors? Thanks!

    Read the article

  • Is arithmetic overflow/underflow generally checked in .Net framework methods?

    - by YWE
    For example, let's use the Add method of the ArrayList class. If I am using the default compiler settings in Visual Studio C# project in which arithmetic overflow is not checked, would ArrayList.Add() throw an OverflowException if I added too many items? Would surrounding the method call with checked or unchecked make any difference? BTW, I would write a test program to determine the answer to this question if I had Visual Studio available to me right now.

    Read the article

  • node.js and jsdom - no way to detect that an http 500 error was returned?

    - by Nathan Ridley
    I'm using jsdom with node.js and I'm trying to get it to provide me with some indication that an http error has occurred. I've set up a test server that simply returns an http 500 header for all requests, but when I attempt to load it with jsdom, jsdom doesn't throw any error and doesn't seem to provide me with any information that would identify that an http 500 error was returned. What's the best way to detect an http 500 error?

    Read the article

  • Rolling back a transaction in a Grails Service

    - by UltraVi01
    I have been updating all my services to be transactional by using Grail's ability to rollback when a RuntimeException is thrown in the service. I have, in most cases, doing this: def domain = new Domain(field: field) if (!domain.save()) { throw new RuntimeException() } Anyways, I wanted to verify that this indeed will rollback the transaction... it got me thinking as to whether at this point it's already been committed.. Also, if not, would setting flush:true change that? I am not very familiar with how Spring/Hibernate does all of this :)

    Read the article

  • exploratory SPARQL queries?

    - by significance
    whenever i start using sql i tend to throw a couple of exploratory statements at the database in order to understand what is avaliable, and what form the data takes. eg. show tables describe table select * from table could anyone help me understand the way to complete a similar exploration of an rdf datastore using a SPARQL endpoint? Thanks :)

    Read the article

  • Getting IBindingList Property to sort by

    - by Josh
    I've got a class called DatagridBoundList that implements CollectionBase and IBindingList. The implementation of IBindingList.ApplySort looks like this so far: void IBindingList.ApplySort(PropertyDescriptor property, ListSortDirection direction) { throw new NotSupportedException(); } I'm binding the DatagridBoundList to a DataGridView (winforms). When I reflect over the property parameter, I can't seem to find the name of the actual property that the list needs to be sorted by. What's the trick to finding out the name of the property to sort by?

    Read the article

< Previous Page | 45 46 47 48 49 50 51 52 53 54 55 56  | Next Page >