GribApiDotNet / GribApi.NET

A powerful .NET library for reading and writing GRIB 1 and 2 files
Apache License 2.0
54 stars 28 forks source link

GribFile::GetEnumerator fails in ASP.NET #12

Closed rzee7 closed 9 years ago

rzee7 commented 9 years ago

Hi Guys,

Thanks a lot for the library you are building, It seems like so easy to use but unfortunately, I tried and not able run this library at my place.

getting this error : error LNK1181: cannot open input file 'zlib.lib'

can you please help me to resolve this?

Thanks in advance RIYAZ

0x1mason commented 9 years ago

@rzee7 Sorry to hear you're having issues. What OS are you using? Can you tell what architecture your project is targeting? Does it happen if you specify x86 or x64? Also, if possible, can you link to a sample GRIB file so I can try to repro?

0x1mason commented 9 years ago

@rzee7 I've pushed a beta package. I believe it may resolve your issue. Can you try installing it?

From the Package Manager Console:

Install-Package Grib.Api -Pre 
rzee7 commented 9 years ago

Hi @0x1mason Thanks a lot giving your time and attention :)

I will try and update you asap.

Again Thanks a lot.

0x1mason commented 9 years ago

Sounds great, lmk.

rzee7 commented 9 years ago

Hi @0x1mason Hope you are doing good. thanks for your effort.

I have build a console application and tried to add GribApi.net from nuget package It works. but the same steps i have tried with in the WebApi solution It doesn't work there. Giving following exception:

{System.TypeInitializationException: An exception was thrown by the type initializer for  Grib.Api.GribFile ---> System.EntryPointNotFoundException: SetDllDirectory
  at (wrapper managed-to-native) Grib.Api.GribEnvironment:SetDllDirectory (string)
  at Grib.Api.GribEnvironment.Init () [0x00041] in c:\Users\eric\GribApi.NET\src\GribApi.NET\Grib.Api\GribEnvironment.cs:86 
  at Grib.Api.GribFile..cctor () [0x00000] in c:\Users\eric\GribApi.NET\src\GribApi.NET\Grib.Api\GribFile.cs:50 
  --- End of inner exception stack trace ---
  at MovingWeather.GribReaderLatest+<>c__DisplayClass9.<ReadGrib2>b__8 () [0x00002] in d:\ii\Projetcs\Git\MovingWeatherV22\MovingWeather\MovingWeather.GribReader\GribReaderLatest.  cs:49 }

Looking forward to here you back.

Thanks RIYAZ

0x1mason commented 9 years ago

I'm happy to hear the console app worked for you, though I'm sorry to hear Web API did not. Does the problem resolve if you set Properties > Build > Platform target: to x86 in your web app?

For example

rzee7 commented 9 years ago

Hi @0x1mason

Thanks a lot for your quick response. Let me try I will ping you soon, :+1:

rzee7 commented 9 years ago

Hi @0x1mason
I have tried the same you suggest but the same issue. :( Is this working your side?

rzee7 commented 9 years ago

See issue in details:

0x1mason commented 9 years ago

The Exception in the pic is different than the trace you posted. In the trace, the problem was SetDllDirectory, in this case it's that it can't find Grib.Api.Native.dll. I haven't been able to reproduce the SetDllDirectory issue, but I have reproduced the Grib.Api.Native.dll problem. You can work around it by copying the Grib.Api directory to "C:\Program Files\IIS Express". I'll push a fix for the problem later today. I'll ping you when it's up.

0x1mason commented 9 years ago

By the way, thank you for your patience and help :+1:

rzee7 commented 9 years ago

Hey @0x1mason Thanks a lot for your instant help :)

That issue has resolved now. bur have another issue is coming while doing grbFile.First() or similar. getting following:

Thanks RIYAZ

0x1mason commented 9 years ago

What are you doing to my library ?!?!? Just joking ;-)

This is great actually--I haven't tested it in a web app. A few questions

1) Does this occur the first time you call grbFile.First()? If "yes", can you share your grib file? 2) Does the same thing happen in a console app? 3) Does the same thing occur in x86 and x64?

rzee7 commented 9 years ago

Hahahaah Hilarious!! :/

you can find full code and a file Here

Thank you @0x1mason

rzee7 commented 9 years ago

Hello @0x1mason

Any luck that may help me :)

Thanks RIYAZ

0x1mason commented 9 years ago

Can't get to this atm. I did notice you weren't using the beta I pushed. You might give that a try.

Also, you can do the grib processing in a console app for now and call the console app from your web app. That at least will unblock you until I can get it debugged. On Oct 20, 2015 4:54 AM, "RIYAZ (Xamarin Students Ambassador)" < notifications@github.com> wrote:

Hello @0x1mason https://github.com/0x1mason

Any luck that may help me :)

Thanks RIYAZ

— Reply to this email directly or view it on GitHub https://github.com/0x1mason/GribApi.NET/issues/12#issuecomment-149482132 .

0x1mason commented 9 years ago

@rzee7 Here's the problem the problem I'm seeing when calling gribFile.First() using the 0.6.0-beta package: When you debug from Visual Studio, IIS Express does some magic copying of your DLLs. The problem is that it can't find the "definitions" folder. The definitions directory is in the "Grib.Api" folder.

There are some changes to the IIS Express config you can make to change how it copies dlls. However, I also got it working by settingGribEnvironment.DefinitionsPath (only needs to be set once, but shouldn't matter):

            GribEnvironment.DefinitionsPath = "C:/path/to/Grib.Api/definitions";
            using (GribFile file = new GribFile("C:/path/to/my/grib.grb"))
            {
               // do stuff...
            }
0x1mason commented 9 years ago

@rzee7 Were you able to get this working?

rzee7 commented 9 years ago

Hi @0x1mason

apologies for the delay, had a long off :) Just came back to my work. Thanks aaa lot!! for your response. I will try this today and get back to you with the result. :+1:

Thanks RIYAZ

0x1mason commented 9 years ago

Hi @rzee7

I released 0.6.0 today. Checkout the part of the README regarding "Shadow Copy". The new GRIB_API_DIR_ROOT environment variable should simplify working with ASP.NET.

Marking this as closed. If you're still having issues, let me know and we can reopen.