Sai Stuff to Developers

September 3, 2014

Problem with ASP.NET using MySQL Connecting through ODBC Driver in some Hosting Servers

Filed under: DotNet — tosaik @ 9:48 am
Tags: , , , , , , ,

Recently i hosted one of my asp.net 4.0 application which is using MySQL as backend and i decided to use MySQL .NET connector to access the MySQL server. I hosted one of the local server and its works fine but i got some consistency issues with my local server and decided to shift my application to GoDaddy which they ensure our application will be 24 X 7 in active.

I moved the application successfully but when i try to run the application through browser i cannot able to connect to database when i dig in to the issue through my logs i came to know that GoDaddy doesn’t support MySQL .NET connector DLL because GoDaddy will run only components and application which are Fully Trusted. When i read the blogs regarding this DLL i came to know Oracle has built this component as partial trusted (medium trust) which means i cannot use anymore with my application to host in GoDaddy. But here i have 2 options

  1. Need to place my MySql .Net connector component to the GAC of GoDaddy server.
  2. Need to remove using MySql .Net connector component in my application.

In the above options, option-1 GoDaddy doesn’t allow me to do so. Now i have only option-2, i removed code related to MySql .Net connector component and removed the reference to it and i try to connect mySQL database through ODBC (Object Database Connector). Which i successfully implemented in my application and working fine on my local computer and i updated the same over the hosting server (in my case GoDaddy), Interestingly still i am unable to connect to the Database, Now when i log my application to find the root cause of the issue, following are the error its throwing:

Request for the permission of type ‘System.Data.Odbc.OdbcPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.

OOPS, i realized that GoDaddy also need my application to be fully trusted which i need to configure in my application via. web.config in System.web section as shown below:

 

<trust level="Full"/>

Once i changed this and made my application full trusted with this simple configuration change, My Application working like a charm.

The reason behind on writing this post is, i worked nearly 5 hrs to fix this issue and i cannot find any direct help from any blogs so i decided to keep this information in my blog to make others time save.

Thank You,

Happy Coding…..

 

October 1, 2013

Launched New Technology Site developersfusion.com

Hi Friends,

I have recently launched a new Technology WebSite www.developersfusion.com .

 

About Developers Fusion

Developers Fusion is a place where the professionals can share their experience and views contributing knowledge to the developer’s community. A successful professional, learns, explores, matures and finally contributes.

The developersfusion.com works with an idea, that has a big vision of bringing Technology to the cozy of your room wherever you are, and make learning comprehensive and exploring Technology real simple and easy.

We are dedicated in providing our Readers quality implementation, education, documentation and solutions. Our ultimate goal is to provide our readers with appropriate solution to their technical questions and needs. The developersfusion.com personifies the passion for Software Technology, delivers power in the technology and the skills associated with it, and enhances the productivity of professionals who shape the software field.

The developersfusion.com believes that it is vital to make learning Technology easy and effective and help its readers, technical breakthroughs in their future career along with other sessions that make them more informed about things that happen around them.

The Articles section lists articles published from different professionals enabling our readers to learn what’s new in the market and also the experience of the author. The FAQs section enables readers to prepare for answering the interview questions shot at them.

Our Vision

Bringing Technology to the cozy of every developer room wherever you are, and make learning comprehensive and exploring Technology real simple and easy.

Our Goal

Our ultimate goal is to provide our readers with appropriate solution to their technical questions and needs.

 

Hope all you make my new website a grand success by visiting posting and participating in forums etc…,

 

Regards,

Sai Kumar K

November 19, 2012

BadImageFormatException: Could not load file or assembly ‘x’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Filed under: DotNet — tosaik @ 12:01 pm
Tags: , , , , ,

Exception:

BadImageFormatException: Could not load file or assembly ‘x’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Solution:

Hi Recenty i had faced this exception and when i digg in to this issue…. and i forgot that when we are using any COM Interop DLL components in our .EXE application we need to target the respective .EXE application platform as x86

Please change the target platform to x86 in the properties section and build again before using it..

 

 

 

 

 

 

 

Hope this solution works for you too………

August 23, 2012

Solution for Parsing an Excel file in C# and the cells seem to get cut off at 255 characters

Filed under: DotNet — tosaik @ 8:10 am
Tags: , , , , ,

Problem: An excel sheet containing say 10 rows and in couple of columns in couple of rows having data with more than 255 characters. When I try to upload this file in ASP.Net application using traditional OLEDB provider I cannot saw the whole data in particular cell means which is chopping out or we can say trimming to 255 characters when loaded in to my dataset object.

Solution: Having done sleepless nights I found some solutions to fix this issue… those are presented below

Solution-1:

If your application is used only on one computer then you can directly go to the following registry settings and change the TypeGuessRows  value.

HKLM\Software\Microsoft\Jet\4.0\Engines\Excel\TypeGuessRows

64 bit systems:

HKLM\SOFTWARE\wow6432node\microsoft\jet\4.0\engines\excel\TypeGuessRows

By setting this value to zero, the all lines of your spreadsheet are scanned for type guessing, rather than the default of 8. If any text fields longer than 255 chars are encountered, then those columns are deemed to be memo fields.

Note that you are still not 100% guaranteed to get the right data types, depending on your data.

Note also the HKLM scope of this key though – it will affect every OleDB Excel import by any process on that machine and this lead to degrade performance depending on the size of the data.

Solution-2:

A second way to work around this problem (without modifying the registry) is to make sure that rows with fields, which have data 255 characters or greater, are present in the first 8 rows (default value of TypeGuessRows is 8) of the source data file.

Solution-3:

This is the recommended solution by me as there is no need to change any registry or take care to have those lengthy data to be in first 8 rows. Instead we have a tool called NPOI which can be download from npoi.codeplex.com.

Using this dll we can upload the spreadsheet without worrying of chopping your data and also it has many features like creating the spreadsheet on fly including charts, reports etc.., for more information you can find on this site npoi.codeplex.com.

Anyway reading data using this NPOI is different from the traditional OLEDB provider. Please find the following method which with return a Data Table object by sending the File Path and the respective SheetName as input.

 
public static DataTable getExcelData(string FileName, string strSheetName)
    {
        DataTable dt = new DataTable();
        HSSFWorkbook hssfworkbook;
        using (FileStream file = new FileStream(FileName, FileMode.Open, FileAccess.Read))
        {
            hssfworkbook = new HSSFWorkbook(file);
        }

        ISheet sheet = hssfworkbook.GetSheet(strSheetName);
        System.Collections.IEnumerator rows = sheet.GetRowEnumerator();
        
        while (rows.MoveNext())
        {
            IRow row = (HSSFRow)rows.Current;

            if (dt.Columns.Count == 0)
            {
                for (int j = 0; j < row.LastCellNum; j++)
                {
                    dt.Columns.Add(row.GetCell(j).ToString());
                }

                continue;
            }

            DataRow dr = dt.NewRow();
            for (int i = 0; i < row.LastCellNum; i++)
            {
                ICell cell = row.GetCell(i);

                if (cell == null)
                {
                    dr[i] = null;
                }
                else
                {
                    dr[i] = cell.ToString();
                }
            }
            dt.Rows.Add(dr);
        }

        return dt;
    }

 May be I presented the solutions straight forward without more explanation or discussion but presently my motto is to provide you the reasonable and permanent solution for those who suffering with similar problem.

Hope this research and the code helps you a lot.. if so please drop a comment below which may be more encroached for me..

 

Happy Coding  🙂

February 18, 2009

Oslo : A new Product From Microsoft

Filed under: DotNet — tosaik @ 7:35 am
Tags:

Making a new class of model-driven applications mainstream

About “Oslo”

”Oslo” is the codename for Microsoft’s forthcoming modeling platform. Modeling is used across a wide range of domains and allows more people to participate in application design and allows developers to write applications at a much higher level of abstraction. “Oslo” consists of:

  • A tool that helps people define and interact with models in a rich and visual manner
  • A language that helps people create and use textual domain-specific languages and data models
  • A relational repository that makes models available to both tools and platform components

“Oslo” was first announced by Robert Wahbe (Corporate Vice President of the Connected Systems Division) in October 2007.

“Oslo” and a Mainstream Approach to Modeling

Modeling has often been heralded as a means to break down technology and role silos in application development to assist IT departments in delivering more effective business strategies. However, while the promise of modeling has existed for decades, it has failed to have a mainstream impact on the way organizations develop and manage their core applications. Microsoft believes that models must evolve to be more than static diagrams that define a software system; they are a core part of daily business discussions, from organizational charts to cash flow diagrams. Implementing models as part of the design, deployment and management process would give organizations a deeper way to define and communicate across all participants and aspects involved in the application lifecycle.

In order to make model-driven development a reality, Microsoft is focused on providing a model-driven platform and visual modeling tools that make it easy for all “mainstream” users, including information workers, developers, database architects, software architects business analysts and IT Professionals, to collaborate throughout the application development lifecycle. By putting model-driven innovation directly into the .NET platform, organizations will gain visibility and control over applications from end-to-end, ensuring they are building systems based on the right requirements, simplifying iterative development and re-use, and enabling them to resolve potential issues at a high level before they start committing resources.

Modeling is a core focus of Microsoft’s Dynamic IT strategy, the company’s long-term approach to provide customers with technology, services and best practices to enable IT and development organizations to be more strategic to the business. “Oslo” is a core piece of delivering on this strategy.

“The benefits of modeling have always been clear, but traditionally only large enterprises have been able to take advantage of it and on a limited scale. We are making great strides in extending these benefits to a broader audience by focusing on three areas. First, we are deeply integrating modeling into our core .NET platform; second, on top of the platform, we then build a very rich set of perspectives that help specific personas in the lifecycle get involved; and finally, we are collaborating with partners and organizations like OMG to ensure we are offering customers the level of choice and flexibility they need.”

Bob Muglia, Senior Vice President, Microsoft Server & Tools Business

“Oslo” and the Future of Application Development

At TechEd United States 2008 (June 2008), Chairman Bill Gates discussed in his keynote the ways in which modeling would transform the future of application development, and the role that “Oslo” plays in these efforts. He also disclosed that a community technology preview (CTP) will be released at the Professional Developers Conference in October 2008.

“I think one of the biggest trends in application development that I talked about… is modeling, and we’re making a big investment in that. We have what’s been code named Oslo, and talked a little bit about it on our Web sites and our blogs, which is this model-driven development platform. It’s actually taking the kind of models that you’re seeing arising in specific domains, like software management in System Center, or your data design over in SQL, or your process activities over in BizTalk and saying, we need to take all these domains and be able to put them into one model space. In fact, we need to let people create their own domains that aren’t just isolated, but that exist in this one modeling space. And that’s what Oslo is about.”

Bill Gates, Chairman, Microsoft

Key features Of Microsoft Visual Studio 2010 and .NET 4.0

Filed under: DotNet — tosaik @ 7:30 am
Tags:

Microsoft announced the next version of its developer platform, which will be named Visual Studio 2010 and .NET Framework 4.0.  Microsoft said VS10 will focus on five key areas (in marketing-speak): riding the next-generation platform wave, inspiring developer delight, powering breakthrough departmental applications, enabling emerging trends such as cloud computing, and democratizing application life-cycle management (ALM).

 

“With Visual Studio 2010 and the .NET Framework 4.0, we are focused on the core pillars of developer experience, support for the latest platforms spanning client, server, services and devices, targeted experiences for specific application types, and core architecture improvements,” said S. Somasegar, senior vice president of the Developer Division at Microsoft.  “These pillars are designed specifically to meet the needs of developers, the teams that drive the application life cycle from idea to delivery, and the customers that demand the highest quality applications across multiple platforms.”

Key features include:

  • Modeling tools.  VS10 will enable both technical and non-technical users to create and use models to collaborate and to define business and system functionality graphically.  VS10 will support both UML and Domain Specific Language support.
  • Improved efficiency throughout the test cycle.  New features include the ability to eliminate non-reproducible bugs, fast setup and deployment of tests to ensure the highest degree of completeness of test, focused test planning and progress tracking, and ensuring that all code changes are properly tested.
  • Substantial improvements in collaboration capabilities.  The capabilities and scalability of Team Foundation Server (TFS) will be improved.  Teams can track work more easily by linking work items with code and models. Visual Studio Team System also introduces workflow-based builds to catch errors before they have a chance to affect the rest of the team or, worse, enter production.
  •  

    The Most Important Feature of .NET 4.0

    First, let’s look at the big picture. .NET 4.0 is not going to have any blockbuster changes at its core like the anonymous method support and generics of .NET 2.0. Nor is it going to be the odd bolt on of half finished products that was .NET 3.0. Nor will it be the language frenzy of .NET 3.5.

    .NET 4.0 is going to include some core changes, particularly in the area of parallel processing that is going to be very important to some people, and will eventually make it into all of our consciousness.

    .NET 4.0 will also include another chance for Entity Framework, and I hope they can finish what they’ve set out to do there. I think there’s a measurable change they’ll create something with broader reach than EF 1.0, but I think it will remain needlessly complex for most projects, and Microsoft has further proven that the data arena is not a place they can be trusted when they announced limited evolution of LINQ to SQL. I hope one day I will say I was needlessly cynical about Microsoft’s data strategy, and I hope that day comes soon. I remain cynical.

    .NET 4.0 will bring Azure and cloud computing to the forefront. That’s cool. For niche applications it’s very powerful stuff. People I respect like David Chappell think this is going to be the main development approach of the future. Maybe. But not right now beyond short term scale out requirements and applications looking for a new delivery mechanism.

    All three of these areas are reasons that I’ll be on my toes as .NET 4.0 unveils itself because it will probably have the largest impact on how I design and code since LINQ. I anticipate that patterns will arise that are important in building applications that will evolve to take advantage of these major Microsoft initiatives (and others).

    Before I go on, I don’t want you to overlook what I just said… I’ve got gray hair and I’ve been in the business a long time…

    .NET 4.0 is likely to offer patterns that will be the most important change in my coding since the huge changes brought on by LINQ (and supporting techniques like extensions and lambdas) of .NET 3.5. That was the most important change to my coding since generics in .NET 2.0. That was the most important change to my coding style since strongly typed full OO programming came on in .NET 1.0. That was the most important change to my coding style since the visual coding style of Visual Basic (pre .NET). That was the most important change to my coding style since Clipper and FoxPro. Get the trend? Eight years, eight years, three years, two years, 18 months… I do a talk for INETA called “Rethinking Object Orientation” that tries to get a grip on these changes… .NET 4.0 is going to bring a lot and inspire a lot of rethinking.

    And so, to stick my neck out and say “this is the most important feature” requires clarification. If we look beyond the long term implications of .NET 4.0 and ask about what it changes in your world the day it ships, beyond incremental improvements, I think there’s only one answer.

    The most important feature of .NET 4.0 is Windows Workflow 4.0.

    Windows Workflow 3.5 gave you a tool for free that previously cost tens of thousands of dollars to get your foot in the door. It was a great opportunity. And there was almost no uptake. I think there were a few reasons – it was too darn hard to use and Microsoft didn’t push it very hard. They probably didn’t push it because it became evident that they screwed it up and it was way too hard to use.

    Windows Workflow 4.0 is a complete rewrite of workflow. It’s a brand new product. More than just rewriting, it represents a rethinking of the problem. It’s not the old giant workflow behemoths pared down to fit into Visual Studio. It give normal developers what they need to incorporate workflow into their applications. If we look beyond forms over data and extend the reach of our applications into helping the organization accomplish its goals, we find workflow. Workflows are a fundamentally better way to think about business problems – and it can often be interleaved with existing applications. Assuming the release is stable as a 1.0 product, and I’m optimistic on that, it’s going to be the thing in .NET 4.0 that lets you add real business value to your applications.

    And real business value is what its all about.

    Important Links :

    Microsoft Visual Studio 2010 Press Release

    CNET: Visual Studio 2010 to come with “black box”

    Create a free website or blog at WordPress.com.